Heartbeat

To keep the connection alive and allow the server to detect disconnected clients, a standard ping/pong heartbeat mechanism is used.

  1. Server ping: The server will send a ping message to your client every 25 seconds.

    • Server Message: {"event":"ping"}

  2. Client pong: Upon receiving a ping, your client must respond with a pong message within 10 seconds.

    • Client Response: {"op":"pong"}

If the server does not receive a pong response from your client within 10 seconds after sending a ping, it will consider the connection stale and will terminate it.

💡 Developer Tip

Most modern WebSocket client libraries (e.g., the browser's WebSocket API, Python's websockets library) handle ping/pong frames automatically. You typically do not need to implement this logic manually. Just ensure your network firewall allows WebSocket control frames to pass through.


Last updated