Skip to content

Connection Issue: ClickHouse Go Driver vs. CLI #1673

@theboringhumane

Description

@theboringhumane

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions