Python socket.io 客户端在带有字典和列表消息的事件上失败
Python socket.io client fails on event with dictionary and list message
我安装了python-socketio==4.3.1,可以正确连接到socket.io服务器。
不过,每当我收到一条消息时,我都会收到异常消息。我将获得的数据将是连接事件的列表和消息事件的字典。
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 581, in _handle_eio_message
self._handle_event(pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 470, in _handle_event
r = self._trigger_event(data[0], namespace, *data[1:])
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 514, in _trigger_event
if namespace in self.handlers and event in self.handlers[namespace]:
TypeError: unhashable type: 'list'
Exception in thread Thread-6:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 581, in _handle_eio_message
self._handle_event(pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 470, in _handle_event
r = self._trigger_event(data[0], namespace, *data[1:])
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 514, in _trigger_event
if namespace in self.handlers and event in self.handlers[namespace]:
TypeError: unhashable type: 'dict'
我能够使用节点客户端正确记录消息。有什么想法吗?
现在的代码就是这样:
import socketio
io = socketio.Client()
@io.event
def connect():
print('connected')
@io.event
def message(data):
print(data)
url = '...'
io.connect(url)
原来错误是在服务器实现中。
我安装了python-socketio==4.3.1,可以正确连接到socket.io服务器。
不过,每当我收到一条消息时,我都会收到异常消息。我将获得的数据将是连接事件的列表和消息事件的字典。
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 581, in _handle_eio_message
self._handle_event(pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 470, in _handle_event
r = self._trigger_event(data[0], namespace, *data[1:])
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 514, in _trigger_event
if namespace in self.handlers and event in self.handlers[namespace]:
TypeError: unhashable type: 'list'
Exception in thread Thread-6:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 581, in _handle_eio_message
self._handle_event(pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 470, in _handle_event
r = self._trigger_event(data[0], namespace, *data[1:])
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 514, in _trigger_event
if namespace in self.handlers and event in self.handlers[namespace]:
TypeError: unhashable type: 'dict'
我能够使用节点客户端正确记录消息。有什么想法吗?
现在的代码就是这样:
import socketio
io = socketio.Client()
@io.event
def connect():
print('connected')
@io.event
def message(data):
print(data)
url = '...'
io.connect(url)
原来错误是在服务器实现中。