我可以连接到节点.jswebsocket服务器使用python websocket。当我询问pythonwebsocket客户机是否连接到服务器时,它是不准确的。在
发生的情况如下:
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
>>> import websocket
>>> ws = websocket.WebSocket()
>>> ws.connect("ws://localhost:8081") # my websocket server is running, so all good here.
>>> ws.connected
True # This is correct. Now I kill the websocker server
>>> ws.connected
True # this should be false since the server is dead.
ws节点.js模块附带wscat
,您可以通过wscat -l 8081
命令运行websocket服务器。在
如何获得指示真实连接/断开连接状态的准确状态?在
不会更新
.connected
属性,除非close
或shutdown
。。。调用,或recv*
接收空数据。在尝试调用
recv()
,然后检查.connected
属性。在相关问题 更多 >
编程相关推荐