# 心跳机制

## 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` |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.infoway.io/websocket-api/heartbeat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
