Keep WebSocket connections alive
To maintain an active WebSocket connection, you need to understand how timeouts work and how to use heartbeat messages.
The server will automatically close any connection that hasn’t received a message in the last 60 seconds. This helps maintain server resources and clean up stale connections.
If you are subscribed to a channel that doesn’t receive regular messages (less than once every 60 seconds), you should send heartbeat messages to keep your connection alive.
Send a ping message in this format:
The server will respond with:
It’s recommended to implement an automatic heartbeat mechanism in your client to send ping messages every 30 seconds if no other messages have been sent.