python websocket客户端连接状态如何更新,使我获得正确的状态?

2024-10-03 06:31:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以连接到节点.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服务器。在

如何获得指示真实连接/断开连接状态的准确状态?在


Tags: the服务器true客户机节点wsserveris