Failed to request and parse

Hi, guys.

I am working with Sonarqube 8.9 LTS version and facing a problem with dotnet sonarscanner…

The GITLAB Pipeline is running sonar-scanner command at windows server.
The message error is Failed to request and parse ‘http://xxxxxxxx:9000/api/server/version’: Object reference not set to an instance of an object.

There is no proxy between the servers.
The problem is that I access this server and type this URL at browser and it returns the Sonarqube version “8.9.0.43852”. There isn’t firewall or proxy between the servers.

I’ve seen some posts about sensitive URL but nothing works for me…
I’m using Dotnet SonarScanner for MSBuild 5.1.

Please, did anybody face it?

I added a step before the scanner with the curl command to check if it’s a network issue and the pipeline called the url no problem. why does the dotnet sonarscanner not work?

Hi,

On the face of it, this is an error in configuring your server location. You said you tried the URL and it works (copy/paste, right?) so I guess there aren’t any typos. Could there be extra whitespace in your configured value? The specific error text indicates to me a problem parsing the server response as json. Maybe check your access log to see exactly what URL is being requested?

 
Ann

Hi, Ann. Thanks for your help…

I’ve checked the access.log and it doesn’t register the access from “dotnet scanner” command. The curious is that access by curl command is registered and the URL is the same.

This is the pipeline commands and results:

$ d:\curl\bin\curl.exe "http://c154vs058930427.br154.corpintra.net:9000/api/server/version"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    11  100    11    0     0    611      0 --:--:-- --:--:-- --:--:--   7338.9.0.43852
$ dotnet sonarscanner begin /k:"%CI_PROJECT_PATH_SLUG%" /d:sonar.login="%UsrSonarToken%" /d:sonar.host.url="http://c154vs058930427.br154.corpintra.net:9000" /d:sonar.verbose=true
SonarScanner for MSBuild 5.1
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Users\d154_s_gitrunner\.dotnet\tools\.store\dotnet-sonarscanner\5.1.0\dotnet-sonarscanner\5.1.0\tools\netcoreapp3.0\any\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\d154_s_gitrunner\.dotnet\tools\.store\dotnet-sonarscanner\5.1.0\dotnet-sonarscanner\5.1.0\tools\netcoreapp3.0\any\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to 'Debug'
Pre-processing started.
Preparing working directories...
Using environment variables to determine the download directory...
14:47:22.164  14:47:22.154  Loading analysis properties from C:\Users\d154_s_gitrunner\.dotnet\tools\.store\dotnet-sonarscanner\5.1.0\dotnet-sonarscanner\5.1.0\tools\netcoreapp3.0\any\SonarQube.Analysis.xml
14:47:22.164  14:47:22.164  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
14:47:22.168  Updating build integration targets...
14:47:22.174  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
14:47:22.174  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
14:47:22.174  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
14:47:22.174  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
14:47:22.175  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
14:47:22.175  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
14:47:22.175  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\d154_s_gitrunner\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
14:47:22.186  Installed SonarQube.Integration.targets to D:\GitLab-Runner\builds\6PpPkfVf\0\infra\visoes\api-visoes\.sonarqube\bin\targets
14:47:22.187  Creating config and output folders...
14:47:22.188  Creating directory: D:\GitLab-Runner\builds\6PpPkfVf\0\infra\visoes\api-visoes\.sonarqube\conf
14:47:22.188  Creating directory: D:\GitLab-Runner\builds\6PpPkfVf\0\infra\visoes\api-visoes\.sonarqube\out
14:47:22.22  Downloading from http://c154vs058930427.br154.corpintra.net:9000/api/server/version...
14:48:25.371  Failed to request and parse 'http://c154vs058930427.br154.corpintra.net:9000/api/server/version': Object reference not set to an instance of an object.
14:48:25.374  Object reference not set to an instance of an object.
14:48:25.376  Pre-processing failed. Exit code: 1
ERROR: Job failed: exit status 1

And here is the Sonarqube access.log (only curl access):

53.93.7.89 - - [09/jun/2021:14:42:39 -0300] "GET /api/server/version HTTP/1.1" 200 - "-" "curl/7.72.0" "AXmvk4pSFb30kQr2ABiV"
53.93.7.89 - - [09/jun/2021:14:47:21 -0300] "GET /api/server/version HTTP/1.1" 200 - "-" "curl/7.72.0" "AXmvk4pSFb30kQr2ABiW"```

Hi,

So I guess it’s official, the server isn’t being reached. Now the question is why, and I’m afraid that’s not something I can help with. I’d start by talking to your network folks.

 
Ann

The host http and not https shouldn’t be the problem to dotnet sonarscanner, right?

Sorry but I’m not qualified to answer that.

 
:slightly_frowning_face:
Ann

I’ve talked to network team and they told me that there isn’t anything blocking the comunication.

So I did 2 tests:

  1. change the sonar host to localhost ip address: It didn’t work. Same error.
  2. change the sonar host to localhost: It worked.

Conclusion: I Think that is a dotnet sonarscanner problem. I Will try to upgrade this version (5.1).

Hi,

Thanks for the update. I’ll be interested to know if the scanner upgrade fixes the problem.

 
Ann