Error in connection between sonar-scanner and sonarqube

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this

Version

  • Sonarqube 10.6
  • Sonar 6.1
  • Docker 27.1
  • WSL (Windows subsytem Linux) 2.2

Hi all, I have Sonarqube deployed in docker, I am trying to perform the scan of a project that is in WSL, but unfortunately I have connection error to retrieve the version. I have already tried to make with curl requests to sonarqube to post 9000, even so it indicates timeout, on the other hand, if I make the request from powershell if I get response, how can I configure the entry of requests from WSL to 9000.

This is the script

sonar-scanner   -Dsonar.projectKey=gestion-horarios   
-Dsonar.sources=.   
-Dsonar.host.url=http://localhost:9000   
-Dsonar.token=sqp_f1aa1b1e4419ebe7d072dd10e6555286d55cccd0 
-X

And, this is the output

juanes-ubuntu@Juanes:~/Repositorios/gestionHorarios$ sonar-scanner   -Dsonar.projectKey=gestion-horarios   -Dsonar.sources=.   -Dsonar.host.url=http://localhost:9000   -Dsonar.token=sqp_f1aa1b1e4419ebe7d072dd10e6555286d55cccd0 -X
15:09:22.151 INFO  Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/6.1.0.4477/libexec/conf/sonar-scanner.properties
15:09:22.157 INFO  Project root configuration file: NONE
15:09:22.187 INFO  SonarScanner CLI 6.1.0.4477
15:09:22.191 INFO  Java 22.0.2 Homebrew (64-bit)
15:09:22.199 INFO  Linux 5.15.153.1-microsoft-standard-WSL2 amd64
15:09:22.213 DEBUG Scanner max available memory: 1 GB
15:09:22.251 DEBUG uname -m returned 'x86_64'
15:09:22.254 DEBUG Create: /home/juanes-ubuntu/.sonar/cache
15:09:22.255 INFO  User cache: /home/juanes-ubuntu/.sonar/cache
15:09:22.255 DEBUG Create: /home/juanes-ubuntu/.sonar/cache/_tmp
15:09:22.734 DEBUG Loaded [413] system trusted certificates
15:09:22.951 DEBUG --> GET http://localhost:9000/api/v2/analysis/version
15:09:22.986 DEBUG <-- HTTP FAILED: java.net.SocketException: Connection reset
15:09:22.987 DEBUG --> GET http://localhost:9000/api/server/version
15:09:22.989 DEBUG <-- HTTP FAILED: java.net.SocketException: Connection reset
15:09:22.990 INFO  EXECUTION FAILURE
15:09:22.991 INFO  Total time: 0.843s
15:09:22.991 ERROR Error during SonarScanner CLI execution
java.lang.IllegalStateException: Failed to get server version
        at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.getServerVersion(ScannerEngineBootstrapper.java:148)
        at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:112)
        at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:63)
Caused by: java.lang.IllegalStateException: Call to URL [http://localhost:9000/api/v2/analysis/version] failed
        at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:178)
        at org.sonarsource.scanner.lib.internal.http.ServerConnection.callApi(ServerConnection.java:145)
        at org.sonarsource.scanner.lib.internal.http.ServerConnection.callRestApi(ServerConnection.java:123)
        at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.getServerVersion(ScannerEngineBootstrapper.java:143)
        ... 3 common frames omitted
Caused by: java.net.SocketException: Connection reset
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:318)
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796)
        at java.base/java.net.Socket$SocketInputStream.implRead(Socket.java:1108)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:1095)
        at okio.InputStreamSource.read(JvmOkio.kt:93)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:128)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:430)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:323)
        at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:180)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:110)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
        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.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
        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.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:176)
        ... 6 common frames omitted

Hi,

I suppose WSL here is Windows Subsystem for Linux (versus the World Surf League :smiley:)? If so, it’s not clear to me why you would do this. Why not just analyze directly from Windows?

 
Ann

Hi Annn
Yes, I can scan the project from windows directly in powershell, but I have the project in WSL (Windows Subsystem for Linux) so I have to perform the scan from “Linux”. I don’t understand why I don’t get the requests to localhost:9000, when I try it, it tells me that it can’t and nothing else :C

Hi,

This is going to be about your networking in and out of WSL. Unfortunately, that’s (waaay) out of my area of expertise. You should pursue this on the WSL side.

 
HTH,
Ann

1 Like

Hello!!
I managed to solve it, it happened that the port was being occupied by another service, and I fixed it by changing the docker script and yap.

docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9001:9000 sonarqube:latest

1 Like

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