mymarilyn / clickhouse-driver

ClickHouse Python Driver with native interface support
https://clickhouse-driver.readthedocs.io
Other
1.19k stars 213 forks source link

clickhouse_driver.errors.SocketTimeoutError #84

Closed 86085185 closed 5 years ago

86085185 commented 5 years ago

code: from clickhouse_driver import Client client = Client('xx.xxx.xx.xx',port=8123,database='default',user='default',password='') client.execute('SHOW tables’)

error: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/connection.py", line 232, in connect self.receive_hello() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/connection.py", line 307, in receive_hello packet_type = read_varint(self.fin) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/reader.py", line 30, in read_varint i = f.read_one() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/bufferedreader.py", line 48, in read_one self.read_into_buffer() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/bufferedreader.py", line 143, in read_into_buffer self.current_buffer_size = self.sock.recv_into(self.buffer) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/client.py", line 191, in execute self.connection.force_connect() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/connection.py", line 166, in force_connect self.connect() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/clickhouse_driver/connection.py", line 240, in connect '{} ({})'.format(e.strerror, self.get_description()) clickhouse_driver.errors.SocketTimeoutError: Code: 209. None (39.96.218.165:8123)

check: curl xx.xxx.xx.xx:8123 ok jdbc connect ok datagrip connect ok

use python3.6,but can not connect clickhouse ,who can help solve the problem????

xzkostyan commented 5 years ago

Hi.

This driver use native protocol (port 9000). Port 8123 is used for HTTP protocol. Use 9000 port.

valevan14 commented 4 years ago

I have this error when connecting clickhouse driver in Google Colab

Failed to connect to https://35.239.148.24:8123 Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/clickhouse_driver/connection.py", line 256, in connect return self._init_connection(host, port) File "/usr/local/lib/python3.6/dist-packages/clickhouse_driver/connection.py", line 226, in _init_connection self.socket = self._create_socket(host, port) File "/usr/local/lib/python3.6/dist-packages/clickhouse_driver/connection.py", line 202, in _create_socket for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known

NetworkError Traceback (most recent call last)

in () 13 ) 14 ---> 15 result = client.execute('SELECT * FROM sleep_money.GiftCards') 16 print("RESULT: {0}: {1}".format(type(result), result)) 17 for t in result: 2 frames /usr/local/lib/python3.6/dist-packages/clickhouse_driver/connection.py in connect(self) 275 276 if err is not None: --> 277 raise err 278 279 def reset_state(self): NetworkError: Code: 210. Name or service not known (None:None) Does anyone know the answer for this issue???
babaralishah commented 2 years ago

Hi.

This driver use native protocol (port 9000). Port 8123 is used for HTTP protocol. Use 9000 port.

Port 9000 is for the clickhouse-client program You must use port 8123 for HTTP.

image

xzkostyan commented 2 years ago

@babaralishah clickhouse-driver use the same interface as clickhouse-client (Native) therefore you should use the same port (9000). Port 8123 is used for handling HTTP requests.

More info at: https://clickhouse.com/docs/en/interfaces/

Fellow-Bennse commented 6 months ago

Getting the 209 Error on 9000 port and unsure how to fix it when on the device with SSH, it also shows that port 9000 is used. IP is correct and ping-able

DantasB commented 3 months ago

What if i'm getting Socket timeout for the port 9000?

mazzletoff3 commented 3 months ago

What if i'm getting Socket timeout for the port 9000?

same problem

DantasB commented 3 months ago

Probably it's some network issue (related to the number of simutaneous connections in the database) or related to the memory @mazzletoff3.

I'm running clickhouse on a ec2 instance and i have about 300 connections in a interval of 6 hours. The instance that i was running was a c5.2xlarge and for that instance, i was getting some socket timeout errors.

I tryied to increase the instance size to a c5.9xlarge and these issues just didn't appear.

The CPU usage was really low, so it can be a memory issue (hard to track on AWS) or network issue (the instance doesn't handle the inumerous connections in a single time).