Unable to connect to server. ... Url: ...?component=unknown'

I’ve recently dusted off an old project and decided to make the CI work again.
One of the steps of this CI is running a GitHub action that uses the SonarQube Cloud.
I haven’t changed the implementation and now the error I’m getting is:

Unable to connect to server. Please check if the server is running and if the address is correct. Url: 'https://sonarcloud.io/api/settings/values?component=unknown'.

If I go that URL, https://sonarcloud.io/api/settings/values?component=unknown, I indeed get an error.
When I replace the “unknown” with my Project Key I get some big JSON result:
https://sonarcloud.io/api/settings/values?component=Marvin-Brouwer_FluentSerializer
So I’m guessing the problem lies with the component part.

However, as I said, I did not change anything.

Things I tried:

Please help me figure this out.

Update:

I’ve tried downgrading the dotnet sonarscanner tool to a version of a year ago.
I don’t get the ?component=unknown part. Yet, I still get a connection error.
On closer inspection of the debug run (line 118), I can see the following line:

System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

It appears the GitHub pipeline, or the dotnet tool is incapable of validating the certificate of https://sonarcloud.io.
I’ve seen many issues on this topic, but most of them are over 4 years ago.

Please help me troubleshoot this further.

Hi,

Thanks for reporting this on the just-release v10. I’ve flagged this for the team.

 
Ann

Hello @Marvin-Brouwer,

It seems that the scanner is not using the expected runtime.
Is there any reason why you are installing the preview version of .NET 9.0?

The SonarScanner for .NET is configured to run on the latest major runtime version available on the machine (see docs).
However, based on my test, this mechanism does not pick up preview versions if there is any stable version installed as well.

If you switch to the stable version of .NET 9.0, it should work out of the box.

If you wish to use the preview version, you will need to somehow update the *.runtimeconfig.json of the scanner.
I don’t know how to do that by installing the global tool, but you can download the scanner from the GitHub release and modify the SonarScanner.MSBuild.runtimeconfig.json like so:

{
  "runtimeOptions": {
    "tfm": "net9",
    "rollForward": "LatestMajor",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "9.0.0"
    },
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false
    }
  }
}

It should ensure to pick the preview version as there is no other matching stable versions available.
You can invoke this version of the scanner like so:

$ dotnet /path/to/scanner/SonarScanner.MSBuild.dll begin ...

In both scenarios, you should be able to drop the downgrade of OpenSSL.

Let me know if it works for you.

Have a good day!

Hi Sebastien,

I think that might be a copy paste error from the other pipeline since I need to support other dotnet versions.
Let me try it without the preview flag.

Thanks,
Marvin

Hi Sebastien,

That was indeed the problem.
Thanks for your help!

2 Likes

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