suharev7 / clickhouse-rs

Asynchronous ClickHouse client library for Rust programming language.
MIT License
324 stars 121 forks source link

Driver error: `Timeout error.` #163

Closed rsalmei closed 3 years ago

rsalmei commented 3 years ago

Hello,

I can connect to a clickhouse instance via curl, but cannot seem to using this lib. Would you have some hunch of what could be wrong? I'm using the latest clickhouse-rs = "1.0.0-alpha.1" in my Cargo.toml.

In curl:

❯ curl 'default:<passwd>@<IP>:8123/?query=SELECT%201'

and it returns instantaneously.

In Rust, I generate this similar URL "tcp://default:<passwd>@<IP>:8123/default?pool_min=1&connection_timeout=2000ms&" and call this:

async fn clickhouse_test(url: String) -> Result<()> {
    println!("Testing clickhouse connection...");
    let pool = Pool::new(url);
    println!("{:?}", pool);
    let x = pool
        .get_handle()
        .await?
        .query("SELECT 1")
        .fetch_all()
        .await?;
    println!(">>>> {:?}", x);
    Ok(())
}

But all I get is a timeout, it never gets to the last println:

Testing clickhouse connection...
Pool { min: 1, max: 20, new connections count: 0, idle connections count: 0, tasks count: 0, ongoing connections count: 0 }
Error: Driver error: `Timeout error.`

Caused by:
    Timeout error.

Thanks.

rsalmei commented 3 years ago

OK, I got it to work. You should make it clearer in the readme that we should use another port, it's not the same as the curl one... For anyone finding this in the future, It had to be the "native TCP/IP protocol endpoint" 9000, not the "HTTP interface" one.