Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Use behind proxy #24

Closed
HadrienMP opened this issue May 11, 2016 · 13 comments
Closed

Use behind proxy #24

HadrienMP opened this issue May 11, 2016 · 13 comments

Comments

@HadrienMP
Copy link

I'm not sure if I haven't configured something poorly, in doubt I'm adding this issue (it can be added to the documentation if it's a configuration issue)

I've configured my proxy in sonar and in maven settings but keep hitting a timeout. Do you have an idea about what I could have done wrong ?

You can find the stack trace below below :

[DEBUG] [sonar4bitbucket] 
Plug-in config: [PluginConfiguration](accountName=pocsonar,repoSlug=poc-sonar,teamName=pocsonar,apiKey=***,oauthTokenClientKey=null,oauthTokenClientSecret=null,branchName=my-branch,approveUnApproveEnabled=true,minSeverity=MAJOR)

[DEBUG] Post-jobs : ch.mibex.bitbucket.sonar.review.SonarReviewPostJob@54366a54
[INFO] Executing post-job ch.mibex.bitbucket.sonar.review.SonarReviewPostJob
mai 11, 2016 1:41:33 PM com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client out-bound request
1 > GET https://bitbucket.org/api/2.0/repositories/pocsonar/poc-sonar/pullrequests?page=1&pagelen=50&state=OPEN
1 > Accept: application/json
1 > Content-Type: application/json
1 > Authorization: Basic cG9jc29uYXI6ckluWjNsf2pFQTVCdzVuellCTjVMWnNRNlMyWWR4dk8=

[INFO] Analysis report generated in C:\java\eclipse-mars\workspace\poc-sonar\target\sonar\batch-report
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.934s
[INFO] Finished at: Wed May 11 13:41:54 CEST 2016
[INFO] Final Memory: 56M/83M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project pocsonar: java.net.ConnectException: Connection timed out: connect -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project pocsonar: java.net.ConnectException: Connection timed out: connect
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.apache.maven.plugin.MojoExecutionException: java.net.ConnectException: Connection timed out: connect
    at org.sonarsource.scanner.maven.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:36)
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:81)
    at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:112)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 25 more
Caused by: com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection timed out: connect
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:151)
    at com.sun.jersey.api.client.filter.LoggingFilter.handle(LoggingFilter.java:183)
    at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:81)
    at com.sun.jersey.api.client.Client.handle(Client.java:648)
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
    at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:507)
    at ch.mibex.bitbucket.sonar.client.BitbucketClient.fetchPage(BitbucketClient.scala:209)
    at ch.mibex.bitbucket.sonar.client.BitbucketClient.ch$mibex$bitbucket$sonar$client$BitbucketClient$$fetchPullRequestsPage$1(BitbucketClient.scala:55)
    at ch.mibex.bitbucket.sonar.client.BitbucketClient$$anonfun$findPullRequestsWithSourceBranch$1.apply(BitbucketClient.scala:72)
    at ch.mibex.bitbucket.sonar.client.BitbucketClient$$anonfun$findPullRequestsWithSourceBranch$1.apply(BitbucketClient.scala:71)
    at ch.mibex.bitbucket.sonar.client.BitbucketClient.forEachResultPage(BitbucketClient.scala:219)
    at ch.mibex.bitbucket.sonar.client.BitbucketClient.findPullRequestsWithSourceBranch(BitbucketClient.scala:71)
    at ch.mibex.bitbucket.sonar.review.SonarReviewPostJob.findPullRequestsForConfiguredBranch(SonarReviewPostJob.scala:36)
    at ch.mibex.bitbucket.sonar.review.SonarReviewPostJob.executeOn(SonarReviewPostJob.scala:18)
    at org.sonar.batch.phases.PostJobsExecutor.execute(PostJobsExecutor.java:65)
    at org.sonar.batch.phases.PostJobsExecutor.execute(PostJobsExecutor.java:55)
    at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:107)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:185)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:243)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:238)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:228)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:55)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:122)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy16.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:78)
    ... 28 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:90)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:380)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:236)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:218)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
    at java.net.Socket.connect(Socket.java:666)
    at com.ibm.jsse2.as.connect(as.java:490)
    at com.ibm.jsse2.ar.connect(ar.java:140)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:192)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at com.ibm.net.ssl.www2.protocol.https.c.<init>(c.java:134)
    at com.ibm.net.ssl.www2.protocol.https.c.a(c.java:82)
    at com.ibm.net.ssl.www2.protocol.https.d.getNewHttpClient(d.java:52)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1118)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1012)
    at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:38)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1528)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1456)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:491)
    at com.ibm.net.ssl.www2.protocol.https.b.getResponseCode(b.java:45)
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:249)
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149)
    ... 69 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

@HadrienMP
Copy link
Author

Any clue what may be causing this ?

@mrueegg
Copy link
Contributor

mrueegg commented May 26, 2016

@HadrienMP Hi. Please excuse the late answer. What happens if you try to connect to Bitbucket from your build server directly, e.g. with cURL:

curl https://bitbucket.org/api/2.0/repositories/pocsonar/poc-sonar/pullrequests?page=1&pagelen=50&state=OPEN

The cause for this issue might be that our plug-in does not respect your proxy settings. How do you configure these?

@HadrienMP
Copy link
Author

HadrienMP commented May 26, 2016

Hi, no need to worry ;).
Right now my proxy is configured in "Internet Options" and in my maven settings.

I tried to build from my development desktop (windows 7). I tried cURL in "cmd" without any luck.

I tried with set https_proxy=https://myproxy:myport and --insecure in the cURL and I managed to get the json.

@mrueegg
Copy link
Contributor

mrueegg commented May 26, 2016

I see. I have to respect the https_proxy environment variable in the plug-in when doing connections to Bitbucket.

Would you be interested to beta-test this once I've implemented it? I could attach a SNAPSHOT to this issue.

@HadrienMP
Copy link
Author

Absolutely !

@mrueegg
Copy link
Contributor

mrueegg commented Jun 1, 2016

Hi,

I have a snapshot ready (see attached) which supports an HTTP proxy. Just configure the parameters like follows:

-Dhttp.proxyHost=http://localhost -Dhttp.proxyPort=9000

Looking forward to your feedback! Thanks
sonar-bitbucket-plugin-1.1.4-SNAPSHOT.zip

mrueegg added a commit that referenced this issue Jun 1, 2016
@mrueegg
Copy link
Contributor

mrueegg commented Jun 20, 2016

Released with version 1.1.4

@mrueegg mrueegg closed this as completed Jun 20, 2016
@HadrienMP
Copy link
Author

Sorry for the delay, I had no time to test the last weeks. I tried the new release without any luck. But maybe I'm still doing something wrong. I get the same error message.

I looked at the code and tried to find the warn message "Going to use proxy" in my maven build logs (in debug mode) but didn't find it. Am I looking at the right place ?

@mrueegg
Copy link
Contributor

mrueegg commented Jul 6, 2016

No problem. You should see this warning message, otherwise the proxy settings are not applied. Could you please make sure that you've specified the proxy settings like follows:

-Dhttp.proxyHost=http://localhost -Dhttp.proxyPort=9000

@HadrienMP
Copy link
Author

I set those variables it in the sonar.properties file (and in my environment variables) is it supposed to be enough ? Is the warn trace supposed to be in the sonar log or the maven log ?

@mrueegg
Copy link
Contributor

mrueegg commented Jul 6, 2016

I wasn't very specific about this. You have to add

-Dhttp.proxyHost=http://localhost -Dhttp.proxyPort=9000

to the command line with which you trigger Maven. You should then see the warning message in the Maven build log.

@HadrienMP
Copy link
Author

It works like a charm now ! Thanks !

@mrueegg
Copy link
Contributor

mrueegg commented Jul 6, 2016

Perfect, thanks for your feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants