SonarLint "Connection refused" 到 SonarQube 6.7

SonarLint "Connection refused" to SonarQube 6.7

自从将 SonarQube 从 6.6 升级到 6.7 后,我遇到了无法将 SonarLint for IntelliJ 与 SonarQube 服务器连接的问题。

我需要配置公司代理,但配置适用于 SonarQube 6.6 并且点击 "Test Connection" 也 returns OK。

配置服务器时的错误信息是:

Failed to connect to the server. Please check the configuration. Error: Fail to request https://mysonardomain/sonar/api/system/status

浏览提到的页面returns一个有效的Json对象:

{
    "id": "xxxxxxxxxxxxxxx",
    "version": "6.7.0.33306",
    "status": "UP"
}

错误日志显示:

Connection test failed
java.lang.IllegalStateException: Fail to request https://mysonardomain.com/sonar/api/system/status 
    at org.sonarsource.sonarlint.core.util.ws.HttpConnector.doCall(HttpConnector.java:179)
    at org.sonarsource.sonarlint.core.util.ws.HttpConnector.get(HttpConnector.java:111)
    at org.sonarsource.sonarlint.core.util.ws.HttpConnector.call(HttpConnector.java:100)
    at org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient.rawGet(SonarLintWsClient.java:114)
    at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.fetchServerInfos(ServerVersionAndStatusChecker.java:97)
    at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.checkVersionAndStatus(ServerVersionAndStatusChecker.java:61)
    at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.checkVersionAndStatus(ServerVersionAndStatusChecker.java:51)
    at org.sonarsource.sonarlint.core.WsHelperImpl.validateConnection(WsHelperImpl.java:60)
    at org.sonarsource.sonarlint.core.WsHelperImpl.validateConnection(WsHelperImpl.java:53)
    at org.sonarlint.intellij.tasks.ConnectionTestTask.run(ConnectionTestTask.java:53)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:713)
    at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:397)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:543)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.application.impl.ApplicationImpl.a(ApplicationImpl.java:575)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:315)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Failed to connect to mysonardomain.com/10.1.1.10:443
    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:223)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:147)
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
    at okhttp3.RealCall.execute(RealCall.java:69)
    at org.sonarsource.sonarlint.core.util.ws.HttpConnector.doCall(HttpConnector.java:176)
... 23 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at okhttp3.internal.platform.Platform.connectSocket(Platform.java:124)
    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:221)
... 41 more

SSL 证书是自签名的,但已添加到 JVM,因此 IntelliJ 知道它(并且没有 SSLHandshakeException)

我正在使用:

还有其他人遇到同样的问题吗?有任何想法吗?是否缺少任何信息?

提前致谢

我几天前更新到 SonarQube 6.7.1 - 这并没有解决问题。

今天我升级到 IntelliJ IDEA 2017.3.3 - 这解决了问题

我不知道到底是什么导致了这个问题,但它已经解决了。

如果负载高,SonarQube 将拒绝请求。

SonarQube在sonar.properties中有一些配置。 您可以在那里优化 maxThreads:

看你的使用情况,默认值很小,我们用这个:

sonar.web.http.maxThreads=500

sonar.web.http.minThreads=100

sonar.web.http.acceptCount=500

负载从哪里来?

  • 例如,Jenkins 通过 maven 插件构建作业
  • IDE Visual Studio、Eclipse 或 ItelliJ 的插件连接到 Sonar 以获得配置文件
  • BitBucket 搜索分支分析报告

我还建议更新 Java 选项:

sonar.web.javaOpts=-Xmx2024m -Xms512m -XX:+HeapDumpOnOutOfMemoryError -server

SonarQube 系统管理页面可帮助您优化值,因为您可以在那里看到当前的使用情况。

/admin/system

注意:重启 SonarQube 服务,而不是使用管理页面上的重启按钮。否则将不会使用新设置。