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

# Heartbeats & Reconnection

> The server pings every 20 seconds, and the protocol is stateless enough that reconnecting is always safe.

## Heartbeats

The server sends a WebSocket protocol-level ping every 20 seconds. Stock client libraries, such as `websockets`, `ws` and `gorilla/websocket`, answer these automatically, so you don't need to write any keepalive code. An idle but healthy connection stays open indefinitely between reports.

## Reconnection

The protocol is stateless beyond the currently open connection. On any disconnect, wait a few seconds, reconnect, and re-subscribe to the channels you care about.

Two things make this safe:

* **Last-value replay** means you're current again immediately after re-subscribing; see [Channels Overview](/channels/overview).
* A plan change closes your connections on purpose, so the next connect picks up the new plan's limits. Treat it like any other disconnect.

<Tip>
  Build your reconnect loop once, with a short backoff, and reuse it everywhere. See the [Examples](/examples/python) section for a complete implementation in four languages.
</Tip>

<Card title="Next: Examples" icon="code" href="/examples/python">
  See runnable client code in Python, Node.js, Go and the browser.
</Card>
