# Ping / Pong

# Overview
To ensure stable and reliable WebSocket connections, we have implemented native ping-pong support in our WebSocket API. This helps detect and close broken connections, preventing clients from holding onto stale sockets.

## How It Works
The WebSocket `ping` is sent from the client to check if the server is still responsive.
The server responds with a `pong` message, confirming that the connection is alive.
If a `pong` response is not received within a certain timeout period, the client should attempt to reconnect.

## Best Practices for Ping Management
A recommended strategy is to send a ping when receiving a heartbeat message from the server. This ensures efficient connection health monitoring without unnecessary traffic.

Example Workflow:


<Steps>
  <Step>
    The server sends a periodic heartbeat message.
      ```json
      {
        "type": "HEARTBEAT",
        "time": 1738602951685555981
      }
      ```
  </Step>
  <Step>
    Upon receiving a heartbeat, the client sends a ping request.
  </Step>
  <Step>
    The server responds with a pong, confirming that the connection is still active.
  </Step>
  <Step>
    If no pong response is received within a timeout period, the client should close the socket and reconnect.
  </Step>
</Steps>