ClickHouse / ClickHouse/clickhouse-go
Connection Issue: ClickHouse Go Driver vs. CLI
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 680
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 14
Description
## Observed
1. **Connecting with the `clickhouse-go` driver to ClickHouse Cloud (Azure & GCP) fails with a `connection reset by peer` error.**
2. **Self-hosted ClickHouse deployments work perfectly fine with the Go driver.**
3. **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
```go
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/ClickHouse/clickhouse-go/v2"
)
func main() {
connStr := "clickhouse://:@:9440/?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
```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
* [x] `clickhouse-go` version: v2.40.3
* [x] Interface: ClickHouse API / `database/sql` compatible driver: database/sql
* [x] Go version: 1.24.0
* [x] Operating system: MacOS/Linux
* [ ] ClickHouse version:
* [x] Is it a ClickHouse Cloud? **Yes (Azure & GCP)**
* [ ] ClickHouse Server non-default settings, if any:
* [ ] `CREATE TABLE` statements 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)](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary
Contributor guide
Research direction
Start with the provided Go example at sql.Open, db.Ping, and SELECT 1, reproducing against ClickHouse Cloud on Azure or GCP with clickhouse-go v2.40.3 and secure=true. Compare the driver's connection and handshake behavior with clickhouse-client; done means the driver connects successfully to Cloud and the example returns 1 without a reset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clickhouse, go
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100