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

# Timeouts and Heartbeats

> Keep WebSocket connections alive

## Overview

To maintain an active WebSocket connection, you need to understand how timeouts work and how to use heartbeat messages.

## Connection Timeout

The server will automatically close any connection that hasn't received a message in the last 60 seconds. This helps maintain server resources and clean up stale connections.

## Heartbeat Messages

If you are subscribed to a channel that doesn't receive regular messages (less than once every 60 seconds), you should send heartbeat messages to keep your connection alive.

### Ping Format

Send a ping message in this format:

```json theme={null}
{
  "method": "ping"
}
```

### Pong Response

The server will respond with:

```json theme={null}
{
  "channel": "pong"
}
```

<Note>
  It's recommended to implement an automatic heartbeat mechanism in your client to send ping messages every 30 seconds if no other messages have been sent.
</Note>
