Sonar Cloud analysis on CircleCI failing with UnknownHostException and SocketException

We are running both the portable sonarqube scanner and MSBuild .Net framework tools on our CircleCI builds (Cloud hosted runners). For a week or two we had been seeing occasional failures with similar exceptions, and for the past day or so the failures have become even more frequent. We are seeing failures in both the begin and end step from the MSBuild tool, and we see failures at the start and middle of the analysis using the portable tool. The majority of failures include the following exception:
java.net.UnknownHostException: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server (scanner.sonarcloud.io)

The problem seems to occur most often when trying to download plugins from the server at the start of the scan e.g. (SonarQube Portable):

06:36:44.486 INFO: Load plugins index
06:36:45.095 DEBUG: GET 200 https://sonarcloud.io/api/plugins/installed | time=609ms
06:36:45.143 INFO: Load plugins index (done) | time=657ms
06:36:45.269 DEBUG: Download plugin 'dbd' to 'C:\Users\circleci.PACKER-62F2A367\.sonar\_tmp\fileCache4924573894248555209.tmp'
06:36:45.348 INFO: Load/download plugins (done) | time=864ms
06:36:45.359 INFO: ------------------------------------------------------------------------
06:36:45.359 INFO: EXECUTION FAILURE
06:36:45.359 INFO: ------------------------------------------------------------------------
06:36:45.360 INFO: Total time: 6.174s
06:36:45.380 INFO: Final Memory: 5M/27M
06:36:45.380 INFO: ------------------------------------------------------------------------
06:36:45.380 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Fail to request https://scanner.sonarcloud.io/plugins/dbd/versions/386e5c50ac6a3af0aa084eac2320bdd9.jar
	at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:186)
	at org.sonarqube.ws.client.HttpConnector.get(HttpConnector.java:110)
	at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:97)
	at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:59)
	at org.sonar.scanner.bootstrap.pluginsdownload.impl.DownloadPluginsScannerWsClientImpl.downloadPlugin(DownloadPluginsScannerWsClientImpl.java:29)
	at org.sonar.scanner.bootstrap.PluginFiles.download(PluginFiles.java:73)
	at org.sonar.scanner.bootstrap.PluginFiles.get(PluginFiles.java:66)
	at org.sonar.scanner.bootstrap.ScannerPluginInstaller.loadPlugins(ScannerPluginInstaller.java:70)
	at org.sonar.scanner.bootstrap.ScannerPluginInstaller.installRemotes(ScannerPluginInstaller.java:52)
	at org.sonar.scanner.bootstrap.ScannerPluginRepository.start(ScannerPluginRepository.java:45)
	at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:26)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	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:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java: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.UnknownHostException: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server (scanner.sonarcloud.io)
	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
	at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(Unknown Source)
	at java.base/java.net.InetAddress.getAddressesFromNameService(Unknown Source)
	at java.base/java.net.InetAddress$NameServiceAddresses.get(Unknown Source)
	at java.base/java.net.InetAddress.getAllByName0(Unknown Source)
	at java.base/java.net.InetAddress.getAllByName(Unknown Source)
	at java.base/java.net.InetAddress.getAllByName(Unknown Source)
	at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
	at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
	at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
	at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
	at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:184)
	... 33 more

We also have run both scans with the SONAR_SCANNER_OPTS=-Djavax.net.debug=all environment variable set which seems to cause a failure on every attempt. This produces both the above exception, and also the following with SonarQube Portable (similar with MSBuild):

04:38:43.062 INFO: ------------------------------------------------------------------------
04:38:43.062 INFO: EXECUTION FAILURE
04:38:43.062 INFO: ------------------------------------------------------------------------
04:38:43.062 INFO: Total time: 6:19.747s
04:38:43.108 INFO: Final Memory: 4M/17M
04:38:43.108 INFO: ------------------------------------------------------------------------
04:38:43.110 ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
	at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
	at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to download scanner-sonarcloud-8.0.0.31704-all.jar to C:\Users\circleci\.sonar\cache\_tmp\fileCache18243848762701542605.tmp
	at org.sonarsource.scanner.api.internal.cache.FileCache.download(FileCache.java:100)
	at org.sonarsource.scanner.api.internal.cache.FileCache.get(FileCache.java:84)
	at org.sonarsource.scanner.api.internal.JarDownloader.lambda$getScannerEngineFiles$0(JarDownloader.java:60)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:61)
	at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
	... 7 more
Caused by: javax.net.ssl.SSLException: Connection reset
	at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.handleException(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(Unknown Source)
	at org.sonarsource.scanner.api.internal.shaded.okio.Okio$2.read(Okio.java:140)
	at org.sonarsource.scanner.api.internal.shaded.okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
	at org.sonarsource.scanner.api.internal.shaded.okio.RealBufferedSource.request(RealBufferedSource.java:72)
	at org.sonarsource.scanner.api.internal.shaded.okio.RealBufferedSource.require(RealBufferedSource.java:65)
	at org.sonarsource.scanner.api.internal.shaded.okio.RealBufferedSource.readHexadecimalUnsignedLong(RealBufferedSource.java:307)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http1.Http1ExchangeCodec$ChunkedSource.readChunkSize(Http1ExchangeCodec.java:492)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http1.Http1ExchangeCodec$ChunkedSource.read(Http1ExchangeCodec.java:471)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Exchange$ResponseBodySource.read(Exchange.java:286)
	at org.sonarsource.scanner.api.internal.shaded.okio.RealBufferedSource$1.read(RealBufferedSource.java:447)
	at java.base/java.io.InputStream.transferTo(Unknown Source)
	at java.base/java.nio.file.Files.copy(Unknown Source)
	at org.sonarsource.scanner.api.internal.ServerConnection.downloadFile(ServerConnection.java:82)
	at org.sonarsource.scanner.api.internal.JarDownloader$ScannerFileDownloader.download(JarDownloader.java:73)
	at org.sonarsource.scanner.api.internal.cache.FileCache.download(FileCache.java:98)
	... 19 more
	Suppressed: java.net.SocketException: Connection reset by peer: socket write error
		at java.base/java.net.SocketOutputStream.socketWrite0(Native Method)
		at java.base/java.net.SocketOutputStream.socketWrite(Unknown Source)
		at java.base/java.net.SocketOutputStream.write(Unknown Source)
		at java.base/sun.security.ssl.SSLSocketOutputRecord.encodeAlert(Unknown Source)
		... 38 more
Caused by: java.net.SocketException: Connection reset
	at java.base/java.net.SocketInputStream.read(Unknown Source)
	at java.base/java.net.SocketInputStream.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(Unknown Source)
	... 34 more

Software Details:

  • Windows Server 2019 10.0 amd64 (also fails on Windows 2022)

SonareQube Portable (Typescript)

  • SonarScanner 4.6.2.2472
  • Java 11.0.11 AdoptOpenJDK (64-bit)

MSBuild .NET Framework (C#)

  • SonarScanner for MSBuild 5.7.2
  • OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

The java version has remained constant and the version of the scanner tools we are using have been cached and unchanged since the problem started. The windows images the VMs use were recently updated, but this was after the problem started occurring. We contacted CircleCI support and they didn’t seem to have any suggestions for changes on their end but noted their windows VMs are located in US east and central regions on GCP which may cause latency issues to the Sonar servers.

There are a few similar posts but none of the advice helped, here are the things we have tried:

  • Increasing the web service timeout to 120 seconds with the sonar.ws.timeout parameter.
  • Allow the JDK each tool uses through the firewall (same as what the firewall popup does when running the scanner locally).
  • Disabling the firewall.
  • Cache the {USERPROFILE}\.sonar\cache folder to stop the plugin downloads from the server. Not sure how other people did this as the logs seem to indicate the cache is overwritten and then the downloads go ahead anyway, e.g.:
01:33:08.524 INFO: User cache: C:\Users\circleci.PACKER-62F2A367\.sonar\cache
01:33:08.535 INFO: Load/download plugins
01:33:08.535 INFO: Load plugins index
01:33:09.150 DEBUG: GET 200 https://sonarcloud.io/api/plugins/installed | time=615ms
01:33:09.198 INFO: Load plugins index (done) | time=663ms
01:33:09.339 DEBUG: Download plugin 'dbd' to 'C:\Users\circleci.PACKER-62F2A367\.sonar\_tmp\fileCache16483137851868004737.tmp'
01:33:09.371 INFO: Load/download plugins (done) | time=836ms
01:33:09.385 INFO: ------------------------------------------------------------------------
01:33:09.385 INFO: EXECUTION FAILURE
01:33:09.385 INFO: ------------------------------------------------------------------------
01:33:09.385 INFO: Total time: 6.173s
01:33:09.406 INFO: Final Memory: 5M/24M
01:33:09.406 INFO: ------------------------------------------------------------------------
01:33:09.406 ERROR: Error during SonarScanner execution

Any help with resolving this issue or a workaround would be appreciated.

Thanks

Hi @mitchell-demol

I think here the firewall could be a first set of investigation. Is there any whitelist to be done for sonarcloud.io or scanner.sonarcloud.io on your side to be able to contact those 2 endpoints ?

Could you check if timeout can be increase on the fw as well ?

Did deactivating it helped in any way ?

Thanks.

Mickaël

Hey,

None of the firewall actions helped.

We currently have a fix for the problem by doing nslookup on sonarcloud.io and scanner.sonarcloud.io and mapping each endpoint to the first IPV4 address found by adding an entry to C:\Windows\System32\Drivers\etc\hosts.

Verified this fixes the problem on a failing build, and haven’t seen any failures using this change.

Thanks,
Mitchell

Thanks for your input, glad you workaround-ed the issue.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.