无法理解来自Clickhouse服务器的错误消息

2024-05-20 03:42:50 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图通过python套接字连接到Clickhouse服务器时,我收到以下消息:

received data:  b'\x02e\x00\x00\x00\x10DB::NetException/DB::NetException: Unexpected packet from client\xf8\x070. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x104191d0 in /usr/bin/clickhouse\n1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x8fff8ad in /usr/bin/clickhouse\n2. ? @ 0x91083e1 in /usr/bin/clickhouse\n3. DB::TCPHandler::runImpl() @ 0x9105bd7 in /usr/bin/clickhouse\n4. DB::TCPHandler::run() @ 0x9107650 in /usr/bin/clickhouse\n5. Poco::Net::TCPServerConnection::start() @ 0x10304f4b in /usr/bin/clickhouse\n6. Poco::Net::TCPServerDispatcher::run() @ 0x103053db in /usr/bin/clickhouse\n7. Poco::PooledThread::run() @ 0x104b2fa6 in /usr/bin/clickhouse\n8. Poco::ThreadImpl::runnableEntry(void*) @ 0x104ae260 in /usr/bin/clickhouse\n9. start_thread @ 0x76db in /lib/x86_64-linux-gnu/libpthread-2.27.so\n10. /build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97: __clone'

这是我的python代码

TCP_IP = "localhost"
TCP_PORT = 9000
BUFFER_SIZE = 1024
MESSAGE = "--user default --password xxxxxxx".encode("utf-8")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
c = s.connect_ex((TCP_IP, TCP_PORT))
print (c)
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()
print ("received data: ", data)

我认为错误来自发送到服务器的错误消息,但当我在Ubuntu终端中键入相同的内容时,它没有错误。我怎么修理它


Tags: runindbdatabinusr错误exception
1条回答
网友
1楼 · 发布于 2024-05-20 03:42:50

它需要跟随ClickHouse Native Protocol Specification以从服务器获取有效响应

查看源代码以获取有关协议的更多详细信息:


对于Python,存在支持ClickHouse本机协议的包clickhouse-driver


我建议不要发出直接TCP请求,而是使用clickhouse-driver-package

相关问题 更多 >