Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

fail to connect to remote clickhouse-server with clickhouse-client

I hosted a clickhouse server on azure VM (I'm able to run clickhouse-client inside the VM) with a nginx proxy, below is the nginx setting

      server {
           listen  5000;
           server_name     myhost.cloudapp.azure.com;
           location / {
                   proxy_pass http://localhost:8123;
           }


   server {
           listen  6000;
           server_name     myhost.cloudapp.azure.com;
           location / {
                   proxy_pass http://localhost:9000;
           }
   

I'm able to curl both endpoint with proper response, e.g.

curl http://myhost.cloudapp.azure.com:6000                
Port 9000 is for clickhouse-client program.
You must use port 8123 for HTTP.

curl http://myhost.cloudapp.azure.com:5000                
Ok.

However, when i try to do clickhouse-client -h myhost.cloudapp.azure.com --port 6000, I get the following.

 clickhouse-client -h myhost.cloudapp.azure.com --port 6000
 ClickHouse client version 21.1.2.15 (official build).
 Connecting to myhost.cloudapp.azure.com:6000 as user default.
 Code: 102. DB::NetException: Unexpected packet from server bs- 
 clickhouse.westeurope.cloudapp.azure.com:6000 (expected Hello or Exception, got Unknown packet)

The connection setting for clickhouse-server is as following:

<listen_host>::</listen_host>

I don't know what I'm doing wrong, any hints are appreciated.

question from:https://stackoverflow.com/questions/65896643/fail-to-connect-to-remote-clickhouse-server-with-clickhouse-client

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

9000 -- tcp protocol not HTTP. You need to configure nginx as TCP reverse proxy

NGINX transparent TCP proxy

stream {
  upstream syslog {
    server sapvmlogstash01.sa.projectplace.com:514;
    server sapvmlogstash02.sa.projectplace.com:514;
  }
  server {
    listen 514;
    proxy_pass syslog;
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...