-
Notifications
You must be signed in to change notification settings - Fork 615
Open
Labels
Description
Observed
- Connecting with the
clickhouse-godriver to ClickHouse Cloud (Azure & GCP) fails with aconnection reset by peererror. - Self-hosted ClickHouse deployments work perfectly fine with the Go driver.
- The official ClickHouse CLI (
clickhouse-client) is able to connect to both cloud and self-hosted environments without any issues.
Expected behaviour
- The Go driver should connect successfully to ClickHouse Cloud deployments (similar to both self-hosted and the CLI client).
Code example
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/ClickHouse/clickhouse-go/v2"
)
func main() {
connStr := "clickhouse://<user>:<password>@<cloud-host>:9440/<database>?secure=true"
db, err := sql.Open("clickhouse", connStr)
if err != nil {
log.Fatalf("sql.Open error: %v", err)
}
defer db.Close()
if err := db.Ping(); err != nil {
log.Fatalf("Ping error: %v", err)
}
var one int
if err := db.QueryRow("SELECT 1").Scan(&one); err != nil {
log.Fatalf("QueryRow error: %v", err)
}
fmt.Println("Result:", one)
}Error log
[clickhouse][4.152.12.124:9440][id=4][handshake] -> 0.0.0
[clickhouse-std][opener] [connect] error connecting to xxxxxx.eastus2.azure.clickhouse.cloud:9440 on connection 4: read: read tcp xxx.168.68.110:53028->x.xxx.xx.124:9440: read: connection reset by peer
Details
Environment
-
clickhouse-goversion: v2.40.3 - Interface: ClickHouse API /
database/sqlcompatible driver: database/sql - Go version: 1.24.0
- Operating system: MacOS/Linux
- ClickHouse version:
- Is it a ClickHouse Cloud? Yes (Azure & GCP)
- ClickHouse Server non-default settings, if any:
-
CREATE TABLEstatements for tables involved: - Sample data for all these tables, use [clickhouse-obfuscator](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary