> For the complete documentation index, see [llms.txt](https://docs.infoway.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infoway.io/websocket-api/heartbeat.md).

# 心跳机制

## API说明

该文档描述了如何对WebSocket连接发送心跳续期，用户需要主动发起心跳续期请求，如果服务端判断WebSocket连接在1分钟内没有发送过心跳请求，将会判定该连接为不活跃连接，并且断开连接请求。请用户合理设计心跳续期逻辑，可以参考[代码示例](/websocket-api/code-examples.md)。

## 请求频率

同一个WebSocket连接，所有的请求（订阅、取消订阅、心跳）限制为**1分钟60次**，如果超出请求频率限制将会自动断连。如果断连次数过多被系统判定为恶意请求将会封禁API Key。请在使用过程中注意调用逻辑。

## 错误码说明

参考[Websocket错误码说明](/getting-started/error-codes/websocket.md)

## 接口地址

请参考[Websocket订阅地址](/websocket-api/endpoints.md)

## 请求（协议号：10010）

```json
{
    "code": 10010,
    "trace": "423afec425004bd8a5e02e1ba5f9b2b0"
}
```

| 参数名     | 类型      | 必填 | 描述           | 示例值                                |
| ------- | ------- | -- | ------------ | ---------------------------------- |
| `code`  | Integer | 是  | 请求的协议号       | 心跳请求协议号：`10010`                    |
| `trace` | String  | 是  | 可追溯ID（随机字符串） | `423afec425004bd8a5e02e1ba5f9b2b0` |
