Socket time out

I have sonarqube server * Community Edition

  • Version 7.9 (build 26994) running on docker container on linux.
    I am running sonar scanning steps from a windows system to analyse a .net framework project.
    Getting following error on every execution.
INFO: Analysis report generated in 66589ms, dir size=45 MB
INFO: Analysis report compressed in 21481ms, zip size=16 MB
ERROR: Failed to delete temp folder
java.nio.file.DirectoryNotEmptyException: E:\sonar-scanner-msbuild-4.9.0.17385-n
et46\.sonarqube\out\.sonar\.sonartmp
        at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
        at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source)
        at java.nio.file.Files.deleteIfExists(Unknown Source)
        at org.sonar.api.utils.internal.DefaultTempFolder$DeleteRecursivelyFileV
isitor.postVisitDirectory(DefaultTempFolder.java:121)
        at org.sonar.api.utils.internal.DefaultTempFolder$DeleteRecursivelyFileV
isitor.postVisitDirectory(DefaultTempFolder.java:110)
        at java.nio.file.Files.walkFileTree(Unknown Source)
        at java.nio.file.Files.walkFileTree(Unknown Source)
        at org.sonar.api.utils.internal.DefaultTempFolder.clean(DefaultTempFolde
r.java:97)
        at org.sonar.api.utils.internal.DefaultTempFolder.stop(DefaultTempFolder
.java:106)
        at org.sonar.scanner.analysis.AnalysisTempFolderProvider.stop(AnalysisTe
mpFolderProvider.java:61)
        at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContai
ner.java:1048)
        at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java
:803)
        at org.sonar.core.platform.ComponentContainer.stopComponents(ComponentCo
ntainer.java:165)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:124)
INFO: ------------------------------------------------------------------------
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContai
ner.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 17:40.160s
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.exec
ute(BatchIsolatedLauncher.java:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(Iso
latedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner
.java:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.j
ava:138)
        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)

INFO: Final Memory: 37M/1074M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Fail to request http://XXX.XXX.X.XXX:5005/api/c
e/submit?projectKey=rmdt
        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.ScannerWsClient.call(ScannerWsClient.java
:75)
        at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:
196)
        at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java
:143)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanC
ontainer.java:366)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContai
ner.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.exec
ute(BatchIsolatedLauncher.java:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(Iso
latedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner
.java:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.j
ava:138)
        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$1.write(AsyncTimeout.java:184)
        at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:179)

        at okio.RealBufferedSink.write(RealBufferedSink.java:42)
        at okhttp3.internal.http1.Http1ExchangeCodec$KnownLengthSink.write(Http1
ExchangeCodec.java:324)
        at okio.ForwardingSink.write(ForwardingSink.java:35)
        at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.j
ava:231)
        at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:179)

        at okio.RealBufferedSink.writeAll(RealBufferedSink.java:107)
        at okhttp3.RequestBody$3.writeTo(RequestBody.java:171)
        at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.java:173)
        at okhttp3.MultipartBody.writeTo(MultipartBody.java:114)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInter
ceptor.java:69)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:117)
        at org.sonarqube.ws.client.OkHttpClientBuilder.addHeaders(OkHttpClientBu
ilder.java:208)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:142)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInter
ceptor.java:43)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:117)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.ja
va:94)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:117)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.j
ava:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:142)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndF
ollowUpInterceptor.java:88)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorCha
in.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.SocketOutputStream.socketWrite(Unknown Source)
        at java.net.SocketOutputStream.write(Unknown Source)
        at okio.Okio$1.write(Okio.java:79)
        at okio.AsyncTimeout$1.write(AsyncTimeout.java:180)
        ... 54 more
ERROR:
The SonarQube Scanner did not complete successfully
15:52:19.838  Post-processing failed. Exit code: 1

Hi,

7.7 is past EOL at this point. You should upgrade at your earliest convenience to the current LTS: 7.9.3, and then on to the current version, 8.3 (8.4 expected next week).

You should also make sure your scanner is at the latest version.

And then you should double-check the directory your analysis is telling you it can’t delete. What are the perms on it. Has the file been locked? We have seen “helpful” processes on Windows lock files, which then interferes with analysis. For the record, we recommend that you don’t run a virus scanner on the machine where analysis runs because they tend to do this sort of thing.

 
HTH,
Ann

Hello Ann,

I am running * Community Edition

  • Version 7.9 (build 26994), i have updated my post.
    For sonar scanner msbuild I am using 4.9.0.** version.
    The commands I am running from cmd (run as administrator), so it should be able to delete the files.
    Tested it with disabling virus scanning as well. But I still face same error.

Hi,

Congrats on your upgrade. I hope you’re enjoying the spiffy new features. :smiley:

Are you able to manually delete that directory?

 
Ann

Hi Ann,

Yes manually deleted the folder.
And anti virus scanning and monitoring stopped. This solved the issue.
Thank you for your help.

1 Like

Hi,

the error caused by default 10s writeTimeout inherited from OkHttp library. While readTimeout is configurable by sonar.ws.timeout param, the writeTimout is not currently configurable. In some cases, depends on the analysis report size and /or your infrastructure setup, 10s is not enough to upload an analysis report that causes socket timeout error and DirectoryNotEmptyException. I have implemented a fix and committed it to SonarSource github: https://github.com/SonarSource/sonarqube/pull/3252/files