ClickHouse / clickhouse-java

ClickHouse Java Clients & JDBC Driver
https://clickhouse.com
Apache License 2.0
1.43k stars 529 forks source link

SSL peer shut down incorrectly #1799

Closed egrishina closed 3 weeks ago

egrishina commented 3 weeks ago

Describe the bug

I am not sure whether this is a bug or just a question. Any help would be highly appreciated.

I am connecting to ClickHouse with DBeaver on a Mac M1. The connection is established correctly, and I can query the nodes successfully. However, in one out of five cases, I get an error (sensitive information is hidden).

Error log

java.sql.SQLException: SSL peer shut down incorrectly, server ClickHouseNode [uri=https://***:443/default, options={socket_timeout=30000,use_server_time_zone=false,use_time_zone=false}]@-399283542
    at com.clickhouse.jdbc.SqlExceptionUtils.handle(SqlExceptionUtils.java:85)
    at com.clickhouse.jdbc.SqlExceptionUtils.create(SqlExceptionUtils.java:31)
    at com.clickhouse.jdbc.SqlExceptionUtils.handle(SqlExceptionUtils.java:90)
    at com.clickhouse.jdbc.internal.ClickHouseStatementImpl.getLastResponse(ClickHouseStatementImpl.java:122)
    at com.clickhouse.jdbc.internal.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:476)
    at com.clickhouse.jdbc.internal.ClickHouseStatementImpl.execute(ClickHouseStatementImpl.java:464)
    at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:330)
    at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:131)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:615)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$2(SQLQueryJob.java:506)
    at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:192)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:525)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:977)
    at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:4176)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
    at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:192)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5160)
    at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:117)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketInputRecord.decode(Unknown Source)
    at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
    at com.clickhouse.client.http.HttpUrlConnectionImpl.post(HttpUrlConnectionImpl.java:225)
    at com.clickhouse.client.http.ClickHouseHttpClient.send(ClickHouseHttpClient.java:124)
    at com.clickhouse.client.AbstractClient.execute(AbstractClient.java:280)
    at com.clickhouse.client.ClickHouseClientBuilder$Agent.sendOnce(ClickHouseClientBuilder.java:282)
    at com.clickhouse.client.ClickHouseClientBuilder$Agent.send(ClickHouseClientBuilder.java:294)
    at com.clickhouse.client.ClickHouseClientBuilder$Agent.execute(ClickHouseClientBuilder.java:349)
    at com.clickhouse.client.ClickHouseClient.executeAndWait(ClickHouseClient.java:1056)
    at com.clickhouse.client.ClickHouseRequest.executeAndWait(ClickHouseRequest.java:2154)
    at com.clickhouse.jdbc.internal.ClickHouseStatementImpl.getLastResponse(ClickHouseStatementImpl.java:120)
    ... 16 more

Session data

eclipse.buildId=unknown
java.version=17.0.6
java.vendor=Eclipse Adoptium
BootLoader constants: OS=macosx, ARCH=aarch64, WS=cocoa, NL=en_US
Framework arguments:  -keyring /Users/***/.eclipse_keyring -eclipse.keyring /Users/***/Library/DBeaverData/secure/secure_storage
Command-line arguments:  -os macosx -ws cocoa -arch aarch64 -keyring /Users/***/.eclipse_keyring

Configuration

Environment

ClickHouse server

chernser commented 3 weeks ago

Good day, @egrishina! Thank you for reporting!

Is the target host a proxy which routes requests to servers? Is there any specific about network - like corporate firewall? Is it possible to try the same on other machine?

Thanks!

egrishina commented 3 weeks ago

Thanks for the reply!

  1. Yes, the request is directed to a load balancer and then forwarded to a Kubernetes cluster where ClickHouse is hosted.
  2. I am connecting to a server via Tailscale VPN. Some kind of firewall is definitely in use.
  3. The same issue is reproduced on all other machines in my team.

I have just tried connecting via another VPN, and it solved the problem - the connection is continuously stable. I am starting to think that the problem lies solely with the original VPN, although I am not sure exactly what causes it.

Anyway, thanks a lot for your input!

chernser commented 3 weeks ago

You are welcome, @egrishina! I'm closing the issue as it seems a network issue.

Thanks!