ClickHouse / clickhouse-odbc

ODBC driver for ClickHouse
https://clickhouse.tech
Apache License 2.0
239 stars 84 forks source link

Error "ERROR [HY000] SSL Exception: Error during handshake: failed to read data" on connect #438

Open avbasov opened 6 months ago

avbasov commented 6 months ago

ODBC driver version 1.2.1.20220905 OS Window 11 Pro

I added an ODBC Data Source with name dwh-01 and URL https://clickhouse-01.int.company.com:8443.

I use a Power Shell script to test the connection

$connectstring = "DSN=dwh-01;Uid=test_user;Pwd=test;"
$sql = @'
show tables;
'@
$connection = New-Object System.Data.Odbc.OdbcConnection($connectstring)
$connection.open()
$command = New-Object system.Data.Odbc.OdbcCommand($sql,$connection)
$data = New-Object system.Data.Odbc.OdbcDataAdapter($command)
$datatable = New-Object system.Data.datatable
$null = $data.fill($datatable)
$conn.close()
$datatable 

The script freezes for a couple of minutes and then throws an error

 Exception calling "Fill" with "1" argument(s): "ERROR [HY000] SSL Exception: Error during handshake: failed to read data"
At line:10 char:1
+ $null = $data.fill($datatable)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : OdbcException

You cannot call a method on a null-valued expression.
At line:11 char:1
+ $conn.close()
+ ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull 

In CH logs I can see

2024.02.01 14:26:08.679925 [ 765 ] {} <Error> ServerErrorHandler: Code: 209. DB::NetException: Timeout exceeded while reading from socket (10.*.*.*:52793, 30000 ms). (SOCKET_TIMEOUT), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c6d5d7b in /usr/bin/clickhouse
1. DB::NetException::NetException<String, long>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<long>::type>, String&&, long&&) @ 0x000000000c975796 in /usr/bin/clickhouse
2. DB::ReadBufferFromPocoSocket::nextImpl() @ 0x000000000c97532c in /usr/bin/clickhouse
3. DB::HTTPServerRequest::HTTPServerRequest(std::shared_ptr<DB::IHTTPContext>, DB::HTTPServerResponse&, Poco::Net::HTTPServerSession&) @ 0x0000000012697fce in /usr/bin/clickhouse
4. DB::HTTPServerConnection::run() @ 0x00000000126965a4 in /usr/bin/clickhouse
5. Poco::Net::TCPServerConnection::start() @ 0x00000000150f4e52 in /usr/bin/clickhouse
6. Poco::Net::TCPServerDispatcher::run() @ 0x00000000150f5c51 in /usr/bin/clickhouse
7. Poco::PooledThread::run() @ 0x00000000151ece67 in /usr/bin/clickhouse
8. Poco::ThreadImpl::runnableEntry(void*) @ 0x00000000151eb45c in /usr/bin/clickhouse
9. ? @ 0x00007fe12cef6609 in ?
10. ? @ 0x00007fe12ce1b353 in ?
 (version 23.12.2.59 (official build))

Clickhouse version 23.12.2.59 (official build) is running in docker. TLS certs are issued by Let's Encrypt. CH SSL configs:

    <openSSL>
        <server>
            <certificateFile>/etc/clickhouse-server/certs/clickhouse-01.int.company.com.crt</certificateFile>
            <privateKeyFile>/etc/clickhouse-server/certs/clickhouse-01.int.company.com.key</privateKeyFile>
            <verificationMode>relaxed</verificationMode>
            <cacheSessions>true</cacheSessions>
            <disableProtocols>sslv2,sslv3</disableProtocols>
            <preferServerCiphers>true</preferServerCiphers>
            <dhParamsFile>/etc/clickhouse-server/certs/dhparam.pem</dhParamsFile>
        </server>
    </openSSL>

Also tried to use the DSN in Excel, but no luck. I'd say it's kind of network problems, but at the same time on the same Windows VM Jetbrains DataGrip with JDBC driver works perfectly fine with the same CH instance.

qq503618737 commented 3 months ago

May be you can try the old version like v1.0.0 20190523

avbasov commented 3 months ago

Sorry can't try it. We have refused to use Power BI. So we don't need this driver anymore.

immivet commented 3 weeks ago

Similar situation. But we do not use a self-signed certificate, but a network-approved one from a certification center Has anyone solved such a problem?