Setting up connected mode in VS Code

[Update: I’ve come across the FAQ now, sorry for not checking those before :man_facepalming: I’ve enabled extended log output and am now indeed seeing some connection issues being reported. I will look into those. I would still expect the plugin to not respond with a success message in such cases, though.]

Apologies if this has been answered before. All of the topics I could find were older ones from early 2019 or even older and still reference settings that no longer seem to exist (specifically, sonarlint.connectedMode.project).

I am trying to set up the Sonarlint plugin (1.15.0) in VS Code (1.42.1 on MacOS 10.15.3) to connect to a remote SonarQube instance in order to set my local ruleset to the project’s rules defined on the server. I have my user and project settings in VS Code set up thus:

User settings:

"sonarlint.connectedMode.connections.sonarqube": [
        "serverUrl": "<server url goes here>",
        "token": "<secret token goes here>"

Project settings:

"sonarlint.connectedMode.project": {
    "projectKey": "<project key goes here>"

This is all in accordance with the help and documentation I could find, both on the Sonarlint plugin settings page in VS Code and on the Sonarlint website. If I then trigger the “SonarLint: Update all project bindings” option, I get back a success message. However, none of my local settings seem to have actually been updated. Moreover, I get the same success message even if I delete all of the settings I’ve described above, so I’m getting the feeling that no actual communication with the server ever takes place.

Accessing the server requires both a VPN connection and (in the browser, at least) an HTTP proxy. The VPN connection is active as I try this; however, I do not have a system-wide proxy configuration; just one in the browser. I would expect to receive an error message from the Sonarlint plugin however in case this was a problem that leads to connection failures.

Is it possible that the success message is a false positive and the connection actually fails silently in the background? How can I verify definitively that everything works as intended? Did I make any mistakes in my settings?

Any help is appreciated, thanks!

Hi @jpkempf

I’m interested to have more details about the connection issues you faced, to understand why there is a success message.

Sure, here’s a dump of the logs that I’m getting so far. Not sure if that helps, but my best bet right now is that the request fails due to the absence of a system-wide proxy configuration, so there would probably be a timeout at some point.

[Info  - 17:26:54.063] Starting SonarTS Server
[Info  - 17:26:57.490] Using typescript at [/Applications/Visual Studio], version 3.7.5
[Info  - 17:26:57.518] SonarTS Server is started
[Info  - 17:26:57.518] SonarTS Server connected to 50679
[Warn  - 17:27:03.782] No storage for server '<default>'. Please update.
[Warn  - 17:28:03.935] No storage for server '<default>'. Please update.
[Error - 17:28:03.937] Error updating storage of the connected SonarLint engine '<default>'
[Error - 17:28:03.938] java.lang.IllegalStateException: Fail to request https://sonarqube.<redacted>.de/api/system/status
	at org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient.rawGet(
	at org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient.get(
	at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.lambda$fetchServerInfos$0(
	at org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient.processTimed(
	at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.fetchServerInfos(
	at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.checkVersionAndStatus(
	at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.checkVersionAndStatus(
	at org.sonarsource.sonarlint.core.container.connected.update.perform.GlobalStorageUpdateExecutor.update(
	at org.sonarsource.sonarlint.core.container.connected.ConnectedContainer.update(
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$update$1(
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.runInConnectedContainer(
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$update$2(
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withRwLock(
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.update(
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.base/java.util.concurrent.ThreadPoolExecutor$
	at java.base/
Caused by: Connect timed out
	at java.base/
	at java.base/
	at java.base/
	at java.base/
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.platform.Platform.connectSocket(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.RealConnection.connectSocket(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.RealConnection.connect(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.ExchangeFinder.findConnection(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.ExchangeFinder.find(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.Transmitter.newExchange(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.connection.ConnectInterceptor.intercept(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.cache.CacheInterceptor.intercept(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.BridgeInterceptor.intercept(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.internal.http.RealInterceptorChain.proceed(
	at org.sonarsource.sonarlint.shaded.okhttp3.RealCall.getResponseWithInterceptorChain(
	at org.sonarsource.sonarlint.shaded.okhttp3.RealCall.execute(
	... 30 more```

Proxy are indeed a concern in VSCode. If your proxy doesn’t require authentification, you should be able to pass -Dhttp.proxyPort=12345 to the SonarLint language server using the VM arguments setting:

That’s good to know! I’m afraid it does require authentication, though :sweat_smile: I might have to go the system-wide proxy way, or perhaps there are tools that proxy connection requests made by certain applications. Will have to research. Any idea why the connection errors never end up in the editor notification?

We tend to avoid being too annoying, especially when there is an issue during on the fly analysis, since it may lead to a lot of recurrent error message.

But when you manually trigger an update of the binding, there should be some feedback. I did some tests, and there is indeed no error message surfacing (but I don’t have a success message either).
I have created a ticket to improve that:

Thanks! Feel free to ping me in case I can provide any additional input on that. Once I figure out my particular problem, I’ll post the solution here.

I’m happy to report that my connection issues are resolved for the moment—I configured Proxifier to catch outbound connection requests from my IDEs to SonarQube and route them through my proxy server. I’ve also confirmed that everything does indeed work, so that’s great! I’m really happy now (apart from the fact that I wasn’t able to solve this issue without having to resort to additional software, but I can hardly blame anyone here for that).

While confirming everthing is working, however, I did come across another confusing thing that I thought I’d mention here. I’ve noticed that the rules that make up the actual quality profile in effect for a project are not reflected properly in the local IDE; instead you see what I think is the default “SonarQube way” list of rules.

WebStorm does include a hint above the list of rules pointing out that these settings might get overridden by a connected server, but VS Code gives no such information. The only way to make sure the correct rules are being enforced is to find a rule that is active on the server but marked as inactive in the IDE, breaking it somewhere deliberately and seeing whether or not the SonarLint plugin complains about it.

Wouldn’t it make sense to actually keep the local quality profiles in sync with the ones coming in from the server? Either as a read-only display or possibly even allowing two-way sync to save changes a user makes in their IDE? At the very least I think there should be a hint displayed in VS Code similar to the one in WebStorm, but it’d be far nicer if a user could actually see the profile that is in effect without having to open the SonarQube web interface.

Besides that, everything is fine now—thank you for your time so far and for providing a great service! :slight_smile:

Hi @jpkempf

Thanks for the update, this is much appreciated, and could be useful for others.

Regarding the confusion about rules configuration panel, your are not the first to report it, so I guess we’ll have to do something about it. The problem is the same in all IDEs (except maybe IntelliJ): you can have in your workspace multiple projects (or root folders), each one having a different binding (or no binding).
So a good UI is not easy to find.

For now our choice is to reserve the rules configuration UI to the configuration of the local quality profile (used by unbound projects). This is not used to visualize the quality profile fetched from the server (we assume you can use SonarQube/SonarCloud UI to do so).

1 Like

I completely understand there may be lots of cases making this more complicated than it seems to me in my current scenario :slight_smile: Thanks for the explanation and keep up the good work!

A post was split to a new topic: ConnectionClosedException in SonarLint VSCode when using a proxy

A post was split to a new topic: Support binding the project on the branch/PR in VSCode