Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expected Hello or Exception, got Unknown packet #242

Closed
leizha opened this issue Aug 21, 2021 · 15 comments
Closed

expected Hello or Exception, got Unknown packet #242

leizha opened this issue Aug 21, 2021 · 15 comments

Comments

@leizha
Copy link

leizha commented Aug 21, 2021

Describe the bug
Client throws this error when running queries.

UnexpectedPacketFromServerError           Traceback (most recent call last)
<ipython-input-6-977623b45362> in <module>
      4 
      5 client = Client("localhost")
----> 6 client.execute("select 123")

/usr/local/lib/python3.9/site-packages/clickhouse_driver-0.2.1-py3.9-macosx-11-x86_64.egg/clickhouse_driver/client.py in execute(self, query, params, with_column_types, external_tables, query_id, settings, types_check, columnar)
    269         start_time = time()
    270         self.make_query_settings(settings)
--> 271         self.connection.force_connect()
    272         self.last_query = QueryInfo()
    273 

/usr/local/lib/python3.9/site-packages/clickhouse_driver-0.2.1-py3.9-macosx-11-x86_64.egg/clickhouse_driver/connection.py in force_connect(self)
    211     def force_connect(self):
    212         if not self.connected:
--> 213             self.connect()
    214 
    215         elif not self.ping():

/usr/local/lib/python3.9/site-packages/clickhouse_driver-0.2.1-py3.9-macosx-11-x86_64.egg/clickhouse_driver/connection.py in connect(self)
    317 
    318             try:
--> 319                 return self._init_connection(host, port)
    320 
    321             except socket.timeout as e:

/usr/local/lib/python3.9/site-packages/clickhouse_driver-0.2.1-py3.9-macosx-11-x86_64.egg/clickhouse_driver/connection.py in _init_connection(self, host, port)
    293 
    294         self.send_hello()
--> 295         self.receive_hello()
    296 
    297         self.block_in = self.get_block_in_stream()

/usr/local/lib/python3.9/site-packages/clickhouse_driver-0.2.1-py3.9-macosx-11-x86_64.egg/clickhouse_driver/connection.py in receive_hello(self)
    437             message = self.unexpected_packet_message('Hello or Exception',
    438                                                      packet_type)
--> 439             raise errors.UnexpectedPacketFromServerError(message)
    440 
    441     def ping(self):

UnexpectedPacketFromServerError: Code: 102. Unexpected packet from server None:None (expected Hello or Exception, got Unknown packet)

To Reproduce

from clickhouse_driver import Client

client = Client("localhost")
client.execute("select 123")

Versions
Python 3.9.6
clickhouse-driver built from commit 78e389e36d20744c236c546ee01ee76d5bc5fb35
Clickhouse server version 21.10.1 revision 54449

@xzkostyan
Copy link
Member

ClickHouse server version 21.10.1 doesn't exist yet.

@leizha
Copy link
Author

leizha commented Aug 23, 2021

@xzkostyan thanks for looking into this.
The bug also repros on latest stable version 21.8.4 revision 54449.
21.10.1 was the latest testing version I tested after stable failed

@xzkostyan
Copy link
Member

Can you provide pip install log in fresh virtual env?

@sunxuming2018
Copy link

I have the same problem. Have you solved it?

Versions
Python 3.6
Clickhouse server version 21.3.4.25

@YNX940214
Copy link

same problem, through ssh tunel

@YNX940214
Copy link

use port 9011 solved it

@xzkostyan
Copy link
Member

Closing due to inactivity.

@stevenhailin
Copy link

I got the same error.
Python 3.10
Clickhouse Server version 20.12.2.1

@ioshumer
Copy link

ioshumer commented Jun 29, 2022

I also got the same:

  • Python 3.10.4
  • clickhouse-driver 0.2.4
  • Clickhouse Server 21.12.2.17

@hustwolf
Copy link

I also got the same:

Python 3.8.5
clickhouse-driver 0.2.4
Clickhouse Server 22.6.2.12

@xzkostyan
Copy link
Member

@hustwolf how can I reproduce your issue?

@tfrokt
Copy link

tfrokt commented Nov 9, 2022

Had the same issue, was using the wrong port. Tried 8123 (HTTP) and 8443 (HTTPS) [1], but 9440 (secure TCP) [2] worked.

clickhouse-driver==0.2.4
Python 3.10.7

[1] https://clickhouse.com/docs/en/interfaces/http/
[2] https://clickhouse.com/docs/en/operations/server-configuration-parameters/settings/#server_configuration_parameters-tcp_port_secure

@XuanmoFeng
Copy link

me too

@brianhumphreys
Copy link

same issue on

Python 3.11.3
clickhouse-driver==0.2.6

@MahRokhK
Copy link

Clickhouse_driver uses Native port of Clickhouse which is based on the TCP protocol instead of http. By default clickhouse has two ports for communicating:
8123: http protocol (most (but not all) of the connections use http protocol like clickhouse-client, clickhouse_connect and ssh connections)
9000: TCP protocol, also known as Native, which clickhouse uses it for its internal communications like the connection between the clickhouse nodes and the clickhouse-keeper of zookeeper. any connection based on tcp needs to be set to this port. such as clickhouse_driver

Just set the port to 9000 ( if you are using the default settings for clickhouse +21.* ) and it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests