Python socketIO-client 连接,然后断开连接



我正在尝试将我的python脚本连接到我的nodejs套接字服务器。我的代码看起来像这样-

节点JS(相关部分)-

//using socket.io@2.0.3
//PORT 8008
io.on('connection', function(socket){
    console.log('connected');
    socket.on('disconnect', function(){
    });
    socket.on('message', function incoming(message){
        console.log(message);
        var data=JSON.parse(message);
        console.log(data);
        socket.broadcast.emit('message', message);
    });
});

蟒蛇脚本(相关部分)-

# using socketIO_client --0.7.2
socketIO = SocketIO('localhost', 8008)
socketIO.wait()

正在控制台中进行连接,但在那之后,我收到错误(在 python 端)-

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 353, in __init__
    resource, hurry_interval_in_seconds, **kw)
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 54, in __init__
    self._transport
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 62, in _transport
    self._engineIO_session = self._get_engineIO_session()
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 76, in _get_engineIO_session
    transport.recv_packet())
StopIteration

我用谷歌搜索并搜索了相关的东西,但直到现在什么都没有。

任何解决方案都值得赞赏。

我在这里找到了这个问题的解决方案:https://github.com/invisibleroads/socketIO-client/issues/159

尝试将 nodejs 的 socket.io 版本从 2.0.3 更改为 1.7.2

最新更新