SonarQube request timed out or was canceled

Please provide

  • Operating system: Windows 11 Pro 22H2
  • SonarLint plugin version: 7.3.0.77872
  • Programming language you’re coding in: c#
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): SonarQube v.9.9.0.65466

I’ am using a personal access token and it seems pretty valid. I just try to curl with it the /api/authentication/validation and it works properly.

The verbose log shows only a generic timed out on the api above, but the api is working and replying in few ms.

Do you have any idea?

[ThreadId 1] Connecting to SonarQube server: https://xyz.com/
[ThreadId 1] Connecting to SonarQube server: Validating credentials
[ThreadId 6] Connecting to 'https://xyz.com/'.
[ThreadId 6] [DEBUG] IsConnected is False.
[ThreadId 6] [DEBUG] Selected SonarQube request factory
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V2_10.GetPluginsRequest for 2.1
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V2_10.GetProjectsRequest for 2.1
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V2_10.GetVersionRequest for 2.1
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V2_60.GetPropertiesRequest for 2.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V3_30.ValidateCredentialsRequest for 3.3
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_00.GetSourceCodeRequest for 5.0
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_10.GetIssuesRequest for 5.1
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_10.GetLanguagesRequest for 5.1
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_20.GetQualityProfileChangeLogRequest for 5.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_20.GetQualityProfilesRequest for 5.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_20.GetRoslynExportProfileRequest for 5.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_40.GetModulesRequest for 5.4
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_50.GetRulesRequest for 5.5
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V5_50.DownloadStaticFile for 5.5
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_20.GetOrganizationsRequest for 6.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_20.GetProjectsRequest for 6.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_30.GetPluginsRequest for 6.3
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_30.GetPropertiesRequest for 6.3
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_50.GetQualityProfileChangeLogRequest for 6.5
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_50.GetQualityProfilesRequest for 6.5
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_60.GetNotificationsRequest for 6.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_60.GetRoslynExportProfileRequest for 6.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V6_60.GetProjectBranchesRequest for 6.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V7_00.GetOrganizationsRequest for 7.0
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V7_20.GetIssuesRequestWrapper for 7.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V8_6.GetHotspotRequest for 8.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V8_6.GetTaintVulnerabilitiesRequest for 8.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V7_20.GetExclusionsRequest for 7.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V9_4.GetSonarLintEventStream for 9.4
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V9_5.GetRulesWithDescriptionSectionsRequest for 9.5
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V9_6.GetRulesWithEducationPrinciplesRequest for 9.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V9_6.GetTaintVulnerabilitiesWithContextRequest for 9.6
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V9_7.SearchHotspotRequest for 9.7
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V10_2.SearchHotspotRequest for 10.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V10_2.GetTaintVulnerabilitiesWithCCTRequest for 10.2
[ThreadId 6] [DEBUG] Registered SonarQube.Client.Api.V10_2.GetRulesWithCCTRequest for 10.2
[ThreadId 6] [DEBUG] Getting the version of SonarQube...
[ThreadId 6] [DEBUG] Looking up implementation of 'IGetVersionRequest' for version '' on thread '6'
[ThreadId 6] [DEBUG] Created request of type 'SonarQube.Client.Api.V2_10.GetVersionRequest'.
[ThreadId 6] [DEBUG] Sending Http request:
[ThreadId 6] [DEBUG] Method: GET, RequestUri: 'api/server/version', Version: 1.1, Content: <null>, Headers:
{
}
[ThreadId 20] [DEBUG] Response with HTTP status code 'OK' received.
[ThreadId 20] [DEBUG] 9.9.0.65466
[ThreadId 20] Connected to SonarQube '9.9.0.65466'.
[ThreadId 20] [DEBUG] Validating the credentials...
[ThreadId 20] [DEBUG] Looking up implementation of 'IValidateCredentialsRequest' for version '' on thread '20'
[ThreadId 20] [DEBUG] Created request of type 'SonarQube.Client.Api.V3_30.ValidateCredentialsRequest'.
[ThreadId 20] [DEBUG] Sending Http request:
[ThreadId 20] [DEBUG] Method: GET, RequestUri: 'api/authentication/validate', Version: 1.1, Content: <null>, Headers:
{
}
[ThreadId 64] SonarQube request timed out or was canceled
[ThreadId 1] Connecting to SonarQube server: Failed
[ThreadId 64] Disconnecting...
[ThreadId 64] [DEBUG] Current state before disconnecting is 'Disconnected'.

Hi @Luca_Bottani - welcome to the community.

We’d expect to see an “invalid credentials” message if there was a problem with token, so we’ll assume it’s ok.

Some questions:

  1. Are you seeing the error every time you open the solution/update the binding, or only intermittently?
  2. Did Connected Mode work correctly for that solution before?
  3. Does Connected Mode work for other users?
  4. Are you able to successfully bind a dummy VS solution to the same Sonar project?

Thanks.

Hi Duncan,

This is the first time we’re attempting to connect to the SonarQube server. It works fine for other users, but only with the Rider IDE and its corresponding plugin (https://plugins.jetbrains.com/plugin/7973-sonarlint). Unfortunately, on some PCs, we can only use Visual Studio.

I attempted to address this issue earlier by creating a dummy project, but I encountered the same problem. What’s strange is that even with a dummy project and a fake token, I never saw the “invalid credentials” message in the logs. The same error keeps occurring.

A colleague of mine also tried different versions of the plugin on Visual Studio, but there was no progress. The same error persists.

PS: different PC, with the same VS and plugin version.

Thanks
Luca

.

Hi Duncan,
we have found the ‘culprit.’ It appears that the instance of SonarCube we are using is, in fact, behind a firewall that analyzes the presence of certain headers in the requests and has a whitelist for the user-agent header. Clearly, for the latter, the SonarLint/VisualStudio x.y.z user agent is not whitelisted. We have temporarily patched the Visual Studio plugin to pass a whitelisted user agent and added the ‘connection’ header. It would be interesting to have the possibility to potentially customize and add headers directly from the GUI.

Thanks.
Luca

2 Likes

Thanks for the feedback @Luca_Bottani - glad you found the underlying issue and a workaround.

Tagging @Marco_Comi as SonarLint PM so he’s aware of the feature request.

1 Like

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