Dotnet-sonarscanner fails to access to server

Hi all,
I’m running a dotnet-sonarscanner within an organisation gitlab instance to access sonarqube instance (which runs on an organisation machine.)

From gitlab pipeline I can see the SonarQube machine:
curl http://MY-SONAR-QUBE-Instance
but can not access /api/server/version when I run the following, it fails (timeout).
curl http://MY-SONAR-QUBE-Instance/api/server/version

Even running the scanner, fails:
dotnet sonarscanner begin /d:sonar.host.url="$SONARQUBE_URL" /d:sonar.verbose=true /k:"$SONARQUBE_PROJECT_KEY" /d:sonar.login=“SONARQUBE_AUTH_TOKEN”

09:00:11.993  Failed to request and parse 'http://MY-SONAR-QUBE-Instance/api/server/version': The operation was canceled.
Unhandled exception. System.Threading.Tasks.TaskCanceledException: The operation was canceled.
 ---> System.IO.IOException: Unable to read data from the transport connection: Operation canceled.
 ---> System.Net.Sockets.SocketException (125): Operation canceled
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
   at System.Net.Http.HttpConnection.FillAsync()
   at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at SonarScanner.MSBuild.PreProcessor.WebClientDownloader.Download(String url, Boolean logPermissionDenied)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass18_0.<<DownloadServerVersion>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func`1 op, String url)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.DownloadServerVersion()
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetServerVersion()
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.WarnIfSonarQubeVersionIsDeprecated()
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.Execute(String[] args)
   at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
   at SonarScanner.MSBuild.BootstrapperClass.Execute()
   at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)
   at SonarScanner.MSBuild.Program.Execute(String[] args)
   at SonarScanner.MSBuild.Program.Main(String[] args)
   at SonarScanner.MSBuild.Program.<Main>(String[] args)

SonarQube version is 7.7.0.23042

Any ideas why we get this error? How can we resolve it?

regards,
Soheil

Please I have a similar problem, with the command:

dotnet sonarscanner begin /k:“newproct” /d:sonar.host.url=“http://mysonarserver:9000” /d:sonar.login=“token”

with the following message:

Failed to request and parse ‘http: // mysonarserver: 9000 / api / server / version’: Object reference not set to an instance of an object.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at SonarScanner.MSBuild.PreProcessor.SonarWebService. <> c__DisplayClass18_0. < b__0> d.MoveNext ()
— End of stack trace from previous location —
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions [T] (Func`1 op, String url)
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DownloadServerVersion ()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetServerVersion ()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.WarnIfSonarQubeVersionIsDeprecated ()
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute (ProcessedArgs localSettings)
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.Execute (String args)
at SonarScanner.MSBuild.BootstrapperClass.PreProcess ()
at SonarScanner.MSBuild.BootstrapperClass.Execute ()
at SonarScanner.MSBuild.Program.Execute (String args, ILogger logger)
at SonarScanner.MSBuild.Program.Execute (String args)
at SonarScanner.MSBuild.Program.Main (String args)
at SonarScanner.MSBuild.Program. (String args)

I have the Sonarqube server 8.8.0
using visual code on linux

Hi @soheils and welcome to the community.

Maybe you want to fix this before going further ? Please note also that your version of SonarQube is not supported anymore. A good move would be to update to the 7.9 LTS (which will be replaced in the coming days by the new LTS (8.9).

Hi @rolandomf1

Can you try to ping this URL from a IWR or IRM powershell command to this is this is scanner related or not ?

Thanks.

I can’t get there with ping, I didn’t realize that.

now if I arrive with ping, but the same problem continues.

What did you do to be able to ping that URL ?