Tuesday, 26 January 2021

Python - How to send heartbeat using websocket-client?

The server requires the client to send a heartbeat every 30 seconds to keep the connection alive. How can I achieve this using python websocket-client library?

import websocket
def on_open(ws):
     pass
def on_close(ws):
     pass
def on_message(ws, message):
     pass

socket = "wss:// the rest of the url"
ws = websocket.WebSocketApp(socket, on_open=on_open,on_message=on_message)
ws.run_forever()

No code runs after ws.run_forever(). How can I send messages ? Thank you



from Python - How to send heartbeat using websocket-client?

No comments:

Post a Comment