【发布时间】:2020-09-22 20:21:02
【问题描述】:
当我尝试通过 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 终端中输入相同的内容时它没有错误。我该如何解决?
【问题讨论】:
-
clickhouse-client 不是命令,请尝试传递有效命令。
-
如果我删除“clickhouse-client”,我仍然会得到同样的结果
标签: python sockets clickhouse