Skip to main content
The realtime client keeps the connection healthy for you. Both reconnect and heartbeat are on by default, and you can tune them in configuration.

Reconnect & subscription restore

If the connection drops by surprise, the client reconnects on its own. It waits a bit longer between each try (exponential backoff) and adds a little random delay (jitter). Once the socket is back, it re-sends every active subscription. After you call close(), it stops trying. Each reconnect try fires a reconnect lifecycle event with the try number and the wait before the next try.
const radion = new Radion({
  apiKey: process.env.RADION_API_KEY,
  realtime: {
    reconnect: {
      initialDelayMs: 500,
      maxDelayMs: 30_000,
      factor: 2,
      jitter: 0.2,
    },
  },
});

radion.realtime.onLifecycle("reconnect", ({ attempt, delayMs }) =>
  console.log(`reconnect #${attempt} in ${delayMs}ms`)
);

// disable auto-reconnect entirely:
// new Radion({ apiKey, realtime: { reconnect: false } });

Heartbeats

The client sends a ping every so often. Any incoming frame proves the connection is alive. If nothing arrives before the timeout, the client treats the connection as dead, closes it, and reconnects.
  • TypeScriptheartbeat: { intervalMs, timeoutMs }, or heartbeat: false to disable.
  • Pythonheartbeat=True/False, heartbeat_interval, heartbeat_timeout (seconds).
  • RustRealtimeOptions::heartbeat(HeartbeatOptions { interval, timeout }) (both Duration), or .disable_heartbeat().
This is separate from the WebSocket ping/pong the server uses at the protocol level. See Connection state for how that works.
Last modified on July 5, 2026