[英]Python socket.io client fails on event with dictionary and list message
我安裝了python-socketio == 4.3.1,並且可以正確連接到socket.io服務器。
但是,每當我收到一條消息時,我都會遇到異常。 我將獲得的數據將是關於connect事件的列表,以及關於消息事件的字典。
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)
原來錯誤是在服務器實現中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.