WebSocket-for-Python
WebSocket-for-Python copied to clipboard
The websocket of zombie.
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.