WebSocket-for-Python icon indicating copy to clipboard operation
WebSocket-for-Python copied to clipboard

The websocket of zombie.

Open laiyazhou opened this issue 6 years ago • 0 comments

from ws4py.client.threadedclient import WebSocketClient

class Client(WebSocketClient):

    def opened(self):
        print("Open")

    def closed(self, code, reason=None):
        print("Closed down:", code, reason)

    def received_message(self, resp):
        data = json.loads(str(resp))
        print(data)

if __name__ == '__main__':
    ws = None
    count = 0
    while True:
        try:
            ws = Client('wss://xxxxxxxxx:xxxxxxxxx')
            ws.connect()
            ws.run_forever()
        except KeyboardInterrupt:
            ws.close()
            break
        except Exception as e:
            continue

Like above of code. when i run the code,after a while,it wont't receive any messages,and it won't TimeoutError,as if the program has frozen.

laiyazhou avatar Dec 27 '18 08:12 laiyazhou