0

我已经安装了 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)
4

1 回答 1

0

原来错误是在服务器实现中。

于 2019-08-28T09:53:31.507 回答