amuniz / bitbucket-branch-source-plugin

5 stars 2 forks source link

Connection timed out with Bitbucket #14

Open BitPan opened 6 years ago

BitPan commented 6 years ago

Hi Team,

After upgraded to version, a lot of our multi-branch projects started to failed to fetch branch information. From Jenkins log I can see a lot of below errors:

org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:504)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:423)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:160)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:404)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:330)
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.executeMethod(BitbucketCloudApiClient.java:534)
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:556)
Caused: java.io.IOException: Communication error for url: https://api.bitbucket.org/2.0/repositories/xxxxx/xxxxxx/hooks?page=1&pagelen=50
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:570)
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:575)
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getWebHooks(BitbucketCloudApiClient.java:403)
Caused: java.io.IOException: I/O error when parsing response from URL: https://api.bitbucket.org/2.0/repositories/xxxxx/xxxxxx/hooks?page=1&pagelen=50
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getWebHooks(BitbucketCloudApiClient.java:417)
    at com.cloudbees.jenkins.plugins.bitbucket.hooks.WebhookAutoRegisterListener.registerHooks(WebhookAutoRegisterListener.java:151)
    at com.cloudbees.jenkins.plugins.bitbucket.hooks.WebhookAutoRegisterListener.access$000(WebhookAutoRegisterListener.java:64)
    at com.cloudbees.jenkins.plugins.bitbucket.hooks.WebhookAutoRegisterListener$1.doRun(WebhookAutoRegisterListener.java:118)
    at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:51)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

This issue seems like caused by exhausted connection pool when Jenkins is trying to make bitbucket API calls. I found a commit here which seems caused this issue. https://github.com/amuniz/bitbucket-branch-source-plugin/commit/238a96d62db283ee891603421707e8f65b078644#diff-66513375f9e876a8924d023aea79a71b.