SonarQube Code Analysis task in Azure DevOps build pipeline fails with error "java.net.SocketTimeoutException: timeout"

Hi,

I’m experiencing some difficulties related to running SonarQube analysis tasks with Azure DevOps build pipelines.

My environment in a nutshell:

  • SonarQube 8.0.0.29455 running in Azure App Service (Windows Web App, Java/Tomcat)
  • Database hosted on Azure SQL Server
  • Azure DevOps for CI/CD instrumentation
  • Self-hosted build agent running on a Azure IaaS VM

I’m in the process of configuring static code analysis for a fairly large (~2M lines of code) Java application. The “Run Code Analysis” task fails each time during the phase when the analysis report is being uploaded to our SonarQube instance:

INFO: Analysis report generated in 17179ms, dir size=313 MB

INFO: Analysis report compressed in 75682ms, zip size=115 MB

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 39:41.360s

INFO: Final Memory: 46M/1559M

INFO: ------------------------------------------------------------------------

##[error]ERROR: Error during SonarQube Scanner execution

java.lang.IllegalStateException: Fail to request https://<url-to-our-SonarQube>/api/ce/submit?projectKey=<redacted>

at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:200)

at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:155)

at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:114)

at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:73)

at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:192)

at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:141)

at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:354)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)

at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)

at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)

at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)

at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)

at com.sun.proxy.$Proxy0.execute(Unknown Source)

at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)

at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)

at org.sonarsource.scanner.cli.Main.execute(Main.java:112)

at org.sonarsource.scanner.cli.Main.execute(Main.java:75)

at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Caused by: java.net.SocketTimeoutException: timeout

at okio.Okio$4.newTimeoutException(Okio.java:232)

at okio.AsyncTimeout.exit(AsyncTimeout.java:286)

at okio.AsyncTimeout$2.read(AsyncTimeout.java:241)

at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)

at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:230)

at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.java:242)

at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.java:213)

at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.java:115)

at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:94)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at org.sonarqube.ws.client.OkHttpClientBuilder.addHeaders(OkHttpClientBuilder.java:208)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221)

at okhttp3.RealCall.execute(RealCall.java:81)

at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:198)

... 25 more

Caused by: java.net.SocketException: Socket closed

at java.net.SocketInputStream.read(SocketInputStream.java:204)

at java.net.SocketInputStream.read(SocketInputStream.java:141)

at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)

at sun.security.ssl.InputRecord.read(InputRecord.java:503)

at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)

at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)

at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)

at okio.Okio$2.read(Okio.java:140)

at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)

... 49 more

ERROR:

ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Despite the error, the report does seem to find its way to our SonarQube instance. An analysis task is being started and also run successfully.

I’m currently a bit at a loss as to what should I look into next in order to get to the bottom of this issue. Even though the analysis is run each time despite the build pipeline failing, ideally we would like to have our pipelines run without such errors. I did find a couple of similar topics elsewhere on the internet but unfortunately the solutions didn’t seem to be relevant to this particular use case.

Thanks,

Br,
Mikko

Anyone?

Even with the debug switch I couldn’t extract anything more useful from the Run Code Analysis task results, just the same error as previously without too much additional information. It does, however, hauntingly seem to be almost precisely 100 seconds from this:

11:48:40.634 DEBUG: Upload report

to this:

11:50:20.503 ERROR: Error during SonarQube Scanner execution

so I would be somewhat hopeful that we’re dealing with a timeout value here, I just don’t have any clue as to which value and where exactly.

I also had “TRACE” level logs on in SonarQube during the scan, but can’t see anything being out of place within those either I’m afraid, other than this single SQL statement which seems to take quite some time to execute:

2020.01.10 09:50:36 TRACE web[<redacted>][sql] time=74440ms | sql=INSERT INTO ce_task_input (task_uuid, created_at, updated_at, input_data) VALUES (?, ?, ?, ?) | params=<redacted>, 1578649762094, 1578649762094, java.io.BufferedInputStream@3a3611a7

Br,
Mikko

Hi @mnieminen and welcome to the community !

Is you whole build fails at 60min precisely ? Or the timeout happen before that ?

Thank you.

Hi @mnieminen
Looks like your scan results in an unusually large report and the connection to the SonarQube server times out during its upload.
Please try to increase the timeout by setting the property sonar.ws.timeout. The value is in seconds.

1 Like