Sonar scan failed with java.net.SocketTimeoutException

Hi All,

I am new to sonar and we are using sonar maven plugin for scanning and we seeing below issue, can someone please help me out in resolving the issue.

We are using sonar 7.4 (build 18908) version.

Please do not close this issue marking as duplicate, Just to let you know we are not using any proxy server in front of sonar server. most of them are saying it as network error due to proxy server.

Note: Out sonar server & sonar maven scan running on two different linux server.

|27-Apr-2020 03:40:16|[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project v3-product: Fail to request http://x.x.x.x:5555/sonarv310uc/api/ce/submit?projectKey=com.vitechinc:v3-product&projectName=%22V3%20Product: timeout: Read timed out -> [Help 1]|
|---|---|
|27-Apr-2020 03:40:16|org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project v3-product: Fail to request http://x.x.x.x:5555/sonarv310uc/api/ce/submit?projectKey=com.vitechinc:v3-product&projectName=%22V3%20Product|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)|
|27-Apr-2020 03:40:16|        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)|
|27-Apr-2020 03:40:16|        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)|
|27-Apr-2020 03:40:16|        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)|
|27-Apr-2020 03:40:16|        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)|
|27-Apr-2020 03:40:16|        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)|
|27-Apr-2020 03:40:16|        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)|
|27-Apr-2020 03:40:16|        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)|
|27-Apr-2020 03:40:16|        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)|
|27-Apr-2020 03:40:16|        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)|
|27-Apr-2020 03:40:16|        at java.lang.reflect.Method.invoke(Method.java:498)|
|27-Apr-2020 03:40:16|        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)|
|27-Apr-2020 03:40:16|        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)|
|27-Apr-2020 03:40:16|        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)|
|27-Apr-2020 03:40:16|        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)|
|27-Apr-2020 03:40:16|Caused by: org.apache.maven.plugin.MojoExecutionException: Fail to request http://x.x.x.x:5555/sonarv310uc/api/ce/submit?projectKey=com.vitechinc:v3-product&projectName=%22V3%20Product|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:67)|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:104)|
|27-Apr-2020 03:40:16|        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)|
|27-Apr-2020 03:40:16|        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)|
|27-Apr-2020 03:40:16|        ... 20 more|
|27-Apr-2020 03:40:16|Caused by: java.lang.IllegalStateException: Fail to request http://x.x.x.x.:5555/sonarv310uc/api/ce/submit?projectKey=com.vitechinc:v3-product&projectName=%22V3%20Product|
|27-Apr-2020 03:40:16|        at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:201)|
|27-Apr-2020 03:40:16|        at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:156)|
|27-Apr-2020 03:40:16|        at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:115)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.bootstrap.ScannerWsClient.call(ScannerWsClient.java:75)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:194)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:140)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.phases.PublishPhaseExecutor.executeOnRoot(PublishPhaseExecutor.java:49)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:79)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)|
|27-Apr-2020 03:40:16|        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)|
|27-Apr-2020 03:40:16|        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)|
|27-Apr-2020 03:40:16|        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)|
|27-Apr-2020 03:40:16|        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)|
|27-Apr-2020 03:40:16|        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)|
|27-Apr-2020 03:40:16|        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)|
|27-Apr-2020 03:40:16|        at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)|
|27-Apr-2020 03:40:16|        at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)|
|27-Apr-2020 03:40:16|        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)|
|27-Apr-2020 03:40:16|        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)|
|27-Apr-2020 03:40:16|        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)|
|27-Apr-2020 03:40:16|        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)|
|27-Apr-2020 03:40:16|        at java.lang.reflect.Method.invoke(Method.java:498)|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)|
|27-Apr-2020 03:40:16|        at com.sun.proxy.$Proxy66.execute(Unknown Source)|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)|
|27-Apr-2020 03:40:16|        at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)|
|27-Apr-2020 03:40:16|        ... 23 more|
|27-Apr-2020 03:40:16|Caused by: java.net.SocketTimeoutException: timeout|
|27-Apr-2020 03:40:16|        at okio.Okio$4.newTimeoutException(Okio.java:227)|
|27-Apr-2020 03:40:16|        at okio.AsyncTimeout.exit(AsyncTimeout.java:284)|
|27-Apr-2020 03:40:16|        at okio.AsyncTimeout$2.read(AsyncTimeout.java:240)|
|27-Apr-2020 03:40:16|        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:344)|
|27-Apr-2020 03:40:16|        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:216)|
|27-Apr-2020 03:40:16|        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:75)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)|
|27-Apr-2020 03:40:16|        at org.sonarqube.ws.client.OkHttpClientBuilder.addHeaders(OkHttpClientBuilder.java:207)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)|
|27-Apr-2020 03:40:16|        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)|
|27-Apr-2020 03:40:16|        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)|
|27-Apr-2020 03:40:16|        at okhttp3.RealCall.execute(RealCall.java:69)|
|27-Apr-2020 03:40:16|        at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:199)|
|27-Apr-2020 03:40:16|        ... 55 more|
|27-Apr-2020 03:40:16|Caused by: java.net.SocketTimeoutException: Read timed out|
|27-Apr-2020 03:40:16|        at java.net.SocketInputStream.socketRead0(Native Method)|
|27-Apr-2020 03:40:16|        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)|
|27-Apr-2020 03:40:16|        at java.net.SocketInputStream.read(SocketInputStream.java:170)|
|27-Apr-2020 03:40:16|        at java.net.SocketInputStream.read(SocketInputStream.java:141)|
|27-Apr-2020 03:40:16|        at okio.Okio$2.read(Okio.java:138)|
|27-Apr-2020 03:40:16|        at okio.AsyncTimeout$2.read(AsyncTimeout.java:236)|

Hello @spalugula,

First thing first:

You should use either the LTS (7.9.x) or the current latest (8.3).
7.4 was an intermediate version, quite old now. Though it’s likely not the cause of your issue.


I’d like to tell you that your error is different, but 1/ it is not, 2/ there’s no real SQ-specific guidance we could give you. The error you see is explicit:

|27-Apr-2020 03:40:16|Caused by: java.lang.IllegalStateException: Fail to request http://x.x.x.x.:5555/sonarv310uc/api/ce/submit?projectKey=com.vitechinc:v3-product&projectName=%22V3%20Product|
[...]
|27-Apr-2020 03:40:16|Caused by: java.net.SocketTimeoutException: Read timed out|

This specific URL did not get an answer. This can have many reasons, but likely not related to SQ:

  • host not reachable (we can exclude this one, I think the error would be explicit)
  • the URL is blocked by an intermediate system (proxy, LB, firewall, etc.). I know you said you had no proxy, but maybe there is one configured on your network and you don’t know about it. A good way to know is to use traceroute <SQ_URL> from the agent to see which route (and servers) the query go through
  • SQ not answering? I doubt but maybe: here a good way to check is to read SQ access.log and see if that query came in or not:
    • if not: the issue is not here
    • if yes: further check at the same time in web.log to see if there was an issue with the request handling

I hope this will help.

Hi Antoine,

Thanks for the update, I will check all out inputs but meanwhile i would like to let you know that we are not seeing this issue continuously and the mentioned issue is intermittent now.

Thanks,
Sunil Palugula

Hi Antoine,

Sorry for the delayed response

Below is my sonar URL and i am getting how to use traceroute.

http://X.X.X.X:5555/sonar

  1. Can you please clarify how to do traceroute for the above SQ_URL if i use following command traceroute <SQ_URL> getting below output.
    $traceroute http://X.X.X.X:5555/sonar
    http://X.X.X.X:5555/sonar: Name or service not known
    Cannot handle “host” cmdline arg `http://X.X.X.X:5555/sonar’ on position 1 (argc 1)

  2. From which servers do you want me to do this traceroute i.e from machine from where we are running scan and the server where sonarqube is hosted.

Thanks,
Sunil Palugula

Hi Antoine,

Did you get chance to look at my previous comment?

Can you please help me out in resolving this issue.

Thanks,
Sunil Palugula

Hello @spalugula,

For this kind of problem, you’d better find help from a networking expert.

Yes indeed, as said:

The general idea is to understand if the machine running the scanner can indeed access SQ, and which intermediate servers the query go through (and potentially alter the query to make it fail). traceroute can only be used with a host (no port nor URL path) as it only validates the needed route to reach that host.

Note that the URL which fail is: http://x.x.x.x.:5555/sonarv310uc/api/ce/submit
This URL is a POST method, submitting a zip file, potentially large. As it is intermittent, it’s likely that an intermediate server (LB, proxy, etc.) forbid requests above a specific size. You should look into that, and/or seek for a network expert help.

Cheers