> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trysoar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connection Keep-Alive

> Send a ping at least every 5 minutes, and reconnect when the server closes.

## Ping

Send a `ping` frame at least every **5 minutes**.

```json theme={null}
{"type":"ping","data":{}}
```

A socket that has not sent a `ping` in 5 minutes is closed without warning.

This is an application-level frame, not a WebSocket protocol ping. Many client
libraries send protocol-level pings automatically; those do **not** satisfy this
requirement. Send the JSON frame.

<Tip>
  Ping on a fixed interval well inside the deadline — every 30 to 60 seconds is
  a comfortable margin — rather than trying to ping exactly at the limit.
</Tip>

## Reconnecting

A server-initiated close is routine. Reconnect and resubscribe.

The server does not send a specific close code on these closes, so most client
libraries will report **1005 ("no status received")**. Do not treat 1005 as an
error condition worth alerting on; treat it as a signal to reconnect.

On reconnect you must redo both halves of your session:

<Steps>
  <Step title="Re-authenticate">
    Send [`authenticate`](/websockets/connection) again if you want your
    private stream. Authentication does not survive a reconnect.
  </Step>

  <Step title="Resubscribe">
    Send your full [`subscribe`](/websockets/subscriptions) target set again.
    Subscriptions do not survive a reconnect either.
  </Step>

  <Step title="Backfill the gap">
    Reload current state over REST for anything you track cumulatively —
    positions, open orders, the order book — because updates that occurred
    while you were disconnected are not replayed.
  </Step>
</Steps>

<Warning>
  There is no message replay. The socket streams what happens while you are
  connected; it does not buffer for absent clients. Any client that needs a
  complete record must reconcile against REST after a reconnect.
</Warning>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.