ネットワーク インフラストラクチャでリクエストがブロックされているため、Jira が外部システムへの webhook 投稿に失敗する

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

問題

Jira で webhook 構成に従ってリモート サービスに webhook コンテンツを投稿することができない。

この webhook は Jira によって適切に生成されている。これはパッケージ com.atlassian.webhooks のログ レベルを DEBUG に設定することで確認できる。

エラーは記録されていない。

実際の webhook が宛先に届かない。

診断

環境

  • ファイアウォール、コンテンツ フィルター、プロキシなどの何らかのネットワーク インフラストラクチャ装置の背後で Jira が実行されている。

Diagnostic Steps

  • この問題の詳細なトラブルシューティングを行うには、パッケージ org.apache.http の DEBUG ログを有効化する必要があります。これにより、Jira が webhook をどのように送信しているかや、どのようなレスポンスを受け取っているかを確認できます。

注意: このログは出力量が非常に多いため、トラブルシューティングを行う場合にのみ有効化し、その後は無効化することをおすすめします。

atlassian-jira.log には次のようなログ メッセージが表示されます。

2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.i.client.cache.CacheInvalidator] Invalidating parent cache entry: null
2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.i.client.cache.CachingHttpAsyncClient] Request is not servable from cache
2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.i.nio.client.MainClientExec] [exchange: 46] start execution
2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.client.protocol.RequestAddCookies] CookieSpec selected: ignoreCookies
2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.client.protocol.RequestAuthCache] Auth cache not set in the context
2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.i.nio.client.InternalHttpAsyncClient] [exchange: 46] Request connection for {s}->https://webhook.site:443
2018-07-03 12:20:05,613 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.InternalHttpAsyncClient] [exchange: 46] Connection allocated: CPoolProxy{http-outgoing-37 [ACTIVE]}
2018-07-03 12:20:05,614 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][r:]: Set attribute http.nio.exchange-handler
2018-07-03 12:20:05,614 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][rw:]: Event set [w]
2018-07-03 12:20:05,614 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][rw:]: Set timeout 0
2018-07-03 12:20:05,614 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][rw:]: Set attribute http.nio.http-exchange-state
2018-07-03 12:20:05,614 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.InternalHttpAsyncClient] Start connection routing
2018-07-03 12:20:05,615 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 Upgrade session x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][rw:][ACTIVE][rw][NEED_UNWRAP][0][0][223][0]
2018-07-03 12:20:05,615 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.MainClientExec] Connection route established
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.MainClientExec] [exchange: 46] Attempt 1 to execute request
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.MainClientExec] Target auth state: UNCHALLENGED
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.MainClientExec] Proxy auth state: UNCHALLENGED
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][rw:][ACTIVE][rw][NEED_UNWRAP][0][0][223][0]: Set timeout 20000
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> POST /2cdfcf07-2abf-4e19-977a-a37d971d7b73?user_id=user&user_key=user HTTP/1.1
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> Accept: */*
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> Content-Type: application/json; charset=UTF-8
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> Via: 1.1 localhost (Apache-HttpClient/4.4.1 (cache))
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> Content-Length: 18919
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> Host: webhook.site
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> Connection: Keep-Alive
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.apache.http.headers] http-outgoing-37 >> User-Agent: Atlassian HttpClient 0.23.3 / JIRA-7.8.0 (78000) / Default
2018-07-03 12:20:05,616 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][rw:][ACTIVE][rw][NEED_UNWRAP][0][0][223][0]: Event set [w]
2018-07-03 12:20:05,664 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 x.x.x.x:pppp<->188.226.137.35:443[ACTIVE][r:r][ACTIVE][rw][NEED_WRAP][inbound done][][379][0][0][0]: Shutdown
2018-07-03 12:20:05,665 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 0.0.0.0:34266<->188.226.137.35:443[CLOSED][][CLOSED][rw][NEED_WRAP][inbound done][][379][0][0][0]: Shutdown
2018-07-03 12:20:05,665 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.client.InternalHttpAsyncClient] [exchange: 46] connection aborted
2018-07-03 12:20:05,665 I/O dispatcher 8 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-37 0.0.0.0:34266<->188.226.137.35:443[CLOSED][][CLOSED][rw][NEED_WRAP][inbound done][][379][0][0][0]: Shutdown

ログ メッセージの exchange 部分 (exchange: 46) は、Web-Hook-Publisher Thread とスレッド内の I/O dispatcher スレッドの対応を示します。

2018-07-03 12:20:05,605 Web-Hook-Publisher-0 DEBUG user 1111111x aaaaaax x.x.x.x,x.x.x.x /secure/WorkflowUIDispatcher.jspa [o.a.h.i.nio.client.InternalHttpAsyncClient] [exchange: 46] Request connection for {s}->https://webhook.site:443

2018-07-03 12:20:05,613 I/O dispatcher 8 DEBUG anonymous [o.a.h.i.nio.client.InternalHttpAsyncClient] [exchange: 46] Connection allocated: CPoolProxy{http-outgoing-37 [ACTIVE]}


ここでは、Jira が webhook ペイロードを送ろうとしたタイミングでコネクションがクローズされていることがわかります。

(info) ログに I/O dispatcher エントリがない場合は次のバグに関連している可能性があります。 JRASERVER-72995 - Getting issue details... STATUS

イベント Event set [w] が 2018-07-03 12:20:05 に記録されたあとは produce contentについてのログが期待されますが、この例ではその代わりに Shutdown メッセージが記録されていて、Jira がコネクションでコンテンツを送信できない状態になっています。

  • Jira で webhook コンテンツを投稿できるかどうかを確認するには、Jira で自分自身または存在しない URI への webhook 投稿を行います。これによって apache http クライアントのデバッグ ログに 404 が記録されます。

webhook でローカルホストの URL に指すよう構成する必要があります。たとえば次のように Jira 自身を指します。http://localhost:<JIRA_PORT>/webhooktest

<JIRA_PORT> は、<Jira インストール ディレクトリ>/conf/server.xml 内の Jira の server.xml にある tomcat コネクタの設定から取得できます。

Jira に "/webhooktest" で定義されている URI はないため、すべての webhook リクエストで 404 レスポンスが返されるはずです。

http クライアントのデバッグ ログには次のようなメッセージが表示されます。 

2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-65 127.0.0.1:57201<->127.0.0.1:8080[ACTIVE][r:w]: Event cleared [w]
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.a.h.i.nio.conn.ManagedNHttpClientConnectionImpl] http-outgoing-65 127.0.0.1:57201<->127.0.0.1:8080[ACTIVE][r:r]: 3237 bytes read
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "HTTP/1.1 404 [\r][\n]"
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "X-AREQUESTID: 11111111111x[\r][\n]"
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "X-XSS-Protection: 1; mode=block[\r][\n]"
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "X-Content-Type-Options: nosniff[\r][\n]"
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "X-Frame-Options: SAMEORIGIN[\r][\n]"
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "Content-Security-Policy: frame-ancestors 'self'[\r][\n]"
2018-07-09 11:51:04,038 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "X-ASEN: SEN-L11812363[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "Set-Cookie: atlassian.xsrf.token=dddd-dddd-dddd-dddd|111111111111111111111111111111111|lout;path=/;Secure[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "X-AUSERNAME: anonymous[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "Set-Cookie: JSESSIONID=JSESSIONIDCOOKIE18CHARACTER;path=/;Secure;HttpOnly[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "Content-Type: text/html;charset=UTF-8[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "Content-Length: 2710[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "Date: Mon, 09 Jul 2018 10:51:03 GMT[\r][\n]"
2018-07-09 11:51:04,039 I/O dispatcher 6 DEBUG anonymous     [o.apache.http.wire] http-outgoing-65 << "[\r][\n]"

404 が確認できる場合、Jira でコンテンツを正常に投稿できており、かつレスポンス (この例では 404) を受け取れていることがわかります。

これにより、問題は Jira そのものではなく外部のネットワーク インフラストラクチャにある可能性があることがわかります。

  • 最後に、Jira サーバーと webhook の宛先の間の接続を確認します。

これは、Jira サーバーのブラウザを利用するか、コマンドラインから curl などのツールを利用することで確認できます (curl は Windows にインストールすることもできます)。

curl を利用する場合は次のコマンドを実行する必要があります。

curl -v -X POST https://<webhook_host>/<webhook-end-point-id>
and
curl -v -X POST http://<webhook_host>/<webhook-end-point-id>

これらのコマンドでは http と https 両方の接続を確認しています。

curl を利用する場合、次の 2 の例のいずれかのような結果が返されます。

  • 1 つめの例: 以下の例では curl が宛先ネットワークに到達するのに失敗していることがわかるため、問題が Jira によるものではないことがわかります。

    [user@jira_host]# curl -v -X POST http://webhook.site/4444444-0000-1111-22222-333333333
    * About to connect() to webhook.site port 80 (#0)
    *   Trying 188.226.137.35... Connection timed out
    *   Trying 2a03:b0c0:0:1010::230:3001... Failed to connect to 2a03:b0c0:0:1010::230:3001: Network is unreachable
    * Success
    * couldn't connect to host
    * Closing connection #0
    curl: (7) Failed to connect to 2a03:b0c0:0:1010::230:3001: Network is unreachable
  • 2 つめの例: 以下の例では、Jira Server が接続先の Webhook を信頼できないために curl が失敗していることがわかります。これは、web サイトの SSL 証明書が Java のトラスト ストアに存在しないためです。

    [user@jira_host]# curl -v -X POST https://webhook.site/4444444-0000-1111-22222-333333333
    Trying 188.226.137.35...
    Connected to webhook.site (188.226.137.35) port 443 (#0)
    Initializing NSS with certpath: sql:/etc/pki/nssdb
    CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
    Server certificate:
    subject: CN=webhook.site,OU=...
    start date: Oct 07 11:52:26 2020 GMT
    expire date: Oct 07 11:52:26 2022 GMT
    common name: webhook.site
    issuer: CN=Something,DC=Something,DC=net
    NSS error -8179 (SEC_ERROR_UNKNOWN_ISSUER)
    Peer's Certificate issuer is not recognized.
    Closing connection 0
    curl: (60) Peer's Certificate issuer is not recognized.
    More details here: http://curl.haxx.se/docs/sslcerts.html
  • If a customized java keystore is in use for the Jira instance, we need to check on this as well. This can be done using the httpclienttest-1.0.2.jar file available here. Run the following command

    <jiraJVM>/java -Djavax.net.debug=all -Djavax.net.ssl.trustStore=<path to keystore as used in JIRA config> -jar httpclienttest-1.0.2.jar "https://<webhook_host>/<webhook-end-point-id>" 

    The result will show similar responses as the curl command above concerning the same causes.


原因

  • 1 つめの例の根本原因は、リクエストの通過を妨げるネットワーク装置があり、それによって Jira がブロックされていることです。
  • 2 つめの例の根本原因は、SSL 経由での Webhook の web サイトが Jira によって信頼されていないことです。これは、Webhook で自己署名証明書を使っていて、それが Java のトラスト ストアにインポートされていないときに発生します。

ソリューション

  • 1 つめの例の修正方法は、Jira をブロックしているネットワーク コンポーネントを特定し、トラフィックを許可するように構成することです
  • 2 つめの例の修正方法は、Webhook の web サイトの SSL 証明書を Jira の Java トラスト ストアにインポートすることです。詳細については「"PKIX Path Building Failed" エラーのために SSL サービスに接続できない」をご確認ください。



最終更新日 2023 年 8 月 23 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.