我正在尝试将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);
});
});
python脚本(相关部分)-
^{pr2}$
在我的控制台中,我得到了连接,但之后,我得到了错误(在python端)——Traceback (most recent call last):
File "", line 1, in
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
我在谷歌上搜索相关的东西,但是到现在为止什么也没有。在
任何解决方法都是值得赞赏的。在
最后
以上就是儒雅冬瓜最近收集整理的关于python socket 主动断开_Python socketIOclient连接然后断开连接的全部内容,更多相关python内容请搜索靠谱客的其他文章。
发表评论 取消回复