ERROR: SonarCloud server [https://sonarcloud.io] can not be reached

Hi,
I am quite new to sonarcloud . I used to be able to use the sonar-scanner for ant to scan our java code for SonarQube (installed inhouse).

Now our company switched to use sonarcloud.io and our LINUX machine does not have internet access directly. It has to go through a proxy server

in my environment, there is

env | grep http
http_proxy=http://xx.xx.xx.xxx:yyyy
https_proxy=http://xx.xx.xx.xxx:yyyy

if I do a “wget sonarcloud.io” , the output is

wget sonarcloud.io
–2024-03-08 23:07:25-- http://sonarcloud.io/
Connecting to xx.xx.xx.xxx:yyyy… connected.
Proxy request sent, awaiting response… 301 Moved Permanently
Location: https://sonarcloud.io/ [following]
–2024-03-08 23:07:25-- https://sonarcloud.io/
Connecting to xx.xx.xx.xxx:yyyy… connected.
Proxy request sent, awaiting response… 307 Temporary Redirect
Location: SonarCloud Online Code Review as a Service Tool [following]
–2024-03-08 23:07:25-- SonarCloud Online Code Review as a Service Tool
Connecting to xx.xx.xx.xxx:yyyy… connected.
Proxy request sent, awaiting response… 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.1’

[ <=>                                                                                       ] 252,063     --.-K/s   in 0.06s

2024-03-08 23:07:25 (3.83 MB/s) - ‘index.html.1’ saved [252063]

It seems the proxy is working and it can connect to sonarcloud.io

But when I tried to run the sonar-scanner command, it always says
ERROR: SonarCloud server [https://sonarcloud.io] can not be reached

I have tried different variations of the command with or without specifying https.proxyHost and https.proxyPort

  1. sonar-scanner -Dsonar.host.url=https://sonarcloud.io/ -Dsonar.token=xxxxxxxx -X
  2. sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=xxxxxxxx -Dhttps.proxyHost=http://xx.xx.xx.xxx/ -Dhttps.proxyPort=yyyy -X
  3. sonar-scanner -Dsonar.host.url=http://sonarcloud.io -Dsonar.token=xxxxxxxx -Dhttps.proxyHost=xx.xx.xx.xxx -Dhttps.proxyPort=yyyy

and their results are look alike

22:45:24.309 INFO: SonarScanner 4.7.0.2747
22:45:24.310 INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
22:45:24.310 INFO: Linux 3.10.0-1160.25.1.0.1.el7.x86_64 amd64
22:45:24.427 DEBUG: keyStore is :
22:45:24.427 DEBUG: keyStore type is : pkcs12
22:45:24.427 DEBUG: keyStore provider is :
22:45:24.427 DEBUG: init keystore
22:45:24.427 DEBUG: init keymanager of type SunX509
22:45:24.526 DEBUG: Create: pwd/.sonar/cache
22:45:24.528 INFO: User cache: pwd/.sonar/cache
22:45:24.528 DEBUG: Create: pwd/.sonar/cache/_tmp
22:45:24.530 DEBUG: Extract sonar-scanner-api-batch in temp…
22:45:24.533 DEBUG: Get bootstrap index…
22:45:24.533 DEBUG: Download: https://sonarcloud.io/batch/index
22:47:24.766 ERROR: SonarCloud server [https://sonarcloud.io] can not be reached
22:47:24.766 INFO: ------------------------------------------------------------------------
22:47:24.766 INFO: EXECUTION FAILURE
22:47:24.766 INFO: ------------------------------------------------------------------------
22:47:24.766 INFO: Total time: 2:00.492s
22:47:24.783 INFO: Final Memory: 3M/40M
22:47:24.784 INFO: ------------------------------------------------------------------------
22:47:24.784 ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
.
.
.
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
.
.
.
Caused by: java.net.SocketTimeoutException: connect timed out
.
.
.
the sonar-project.properties file in my project is very basic

sonar.projectKey=“ZZZZZZ”
sonar.projectName=“ZZZZZZ”
sonar.projectVersion=“1.0”
sonar.language=“java”
sonar.sources=“src”
sonar.java.binaries=“dist”
sonar.sourceEncoding=“UTF-8”
sonar.userHome=pwd/.sonar

And i did not configure the sonar-scanner.properties file

Hope someone with more knowledge can point out what I have been missing in my setup

Thanks,
James

Hello James,

Can you confirm your proxy server, firewall, or network infrastructure is not blocking downloads of jar files? In the 22:45:24.533 DEBUG: Download: https://sonarcloud.io/batch/index step, there is a download of a jar file.

Thanks Joe, I will have to check with the IT network security people.

I am having the same issue when trying to pass it through a proxy.

The flags do not appear to have an effect on Azure Devops pipeline task(Windows 10 custom agents), nor the sonarcloud-cli JAR. (windows 11 and WSL )
Conversely I tested the URL with curl to verify it works with the proxy. Other threads on this issue never seem to reach resolution…

Can you show your logs showing the error? What version of the ADO tasks are you using?

Our IT said the proxy should allow download of jar, so I tried the curl command and it is showing this

curl https://sonarcloud.io/batch/index
scanner-sonarcloud-8.0.0.53342-all.jar|10f9495a9f0e38ed52e553579a94ba76

does it mean it can connect and dowloaded the jar file with the index??

Thanks

No, that curl of that /batch/index does not download a jar. That fetches a string of the jar to download with a checksum to check the download.

You need to curl for that jar from your Linux machine or build agent or wherever your pipeline is:

curl 'https://sonarcloud.io/batch/file?name=scanner-sonarcloud-8.0.0.53342-all.jar' -o output.jar   

Thank you Joe for the curl command, I ran it in the LINUX box and I see the output.jar file is downloaded/created.

so looks like the proxy is not blocking the download. And I will need to find out why the sonar-scanner command cannot perform the download

Does anyone know how to skip the download of the jar file when running the sonar-scanner CLI ?

No, you can’t do that if you want to scan a project.

Are you still having issues with connection time out? Can you ask your network team to temporarily disable the firewall on that LINUX box and see what happens? If it works, then its the network team’s problem. If it doesn’t work, there’s something else you need to check.

Want to report back that the sonar support team helped solved the probem.

The commandline option -Dhttps.proxyHost and -Dhttps.proxyPort could not be used directly in the commandline. Instead we need to do the following :

export SONAR_SCANNER_OPTS=“-Dhttps.proxyHost=xx.xx.xx.xxx -Dhttps.proxyPort=xxxx”

And then run the sonar-scanner command with the token, organization and projectKey

And it finally scanned successfully.

Thanks to them and also thanks to everyone who gave me suggestions

Cheers,
James

1 Like

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