Skip to content

补充websocket连接流程文档 #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/zh-cn/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Gateway 的地址需要走 http 接口获取,参见[Gateway](https://developer
常规连接流程如下:

1. 获取 Gateway
2. 连接 Gateway。如果连接失败,回退到第 1 步。
2. 连接 Gateway。如果成功,进入到第3步;如果连接失败,进入到指数回退,最多重试两次(间隔为2,4),回退到第 1 步。
3. 收到 hello 包,如果成功,开始接收事件。如果失败,回退至第 1 步。
4. 在连接中,每隔 30 秒发一次心跳 ping 包,如果 6 秒内,没有收到心跳 pong 包,则超时。进入到指数回退,重试。
5. 先发两次心跳 ping(间隔为 2,4),判断连接是否成功。如果成功,则连接恢复。
6. 如果不成功,再回退到第 2 步,尝试两次 resume(间隔为 8,16)。如果成功,会按正常往下走,但有一个 resume 过程(同步中间的离线消息),resume 完了,会收到一个 resumeOK 包。
6. 如果不成功,再回退到第 2 步,尝试两次 resume(具体参考下文关于重连,间隔为 8,16)。如果成功,会按正常往下走,但有一个 resume 过程(同步中间的离线消息),resume 完了,会收到一个 resumeOK 包。
7. 如果失败,再回到第 1 步,尝试无数次获取 Gateway(指数倒退,最大间隔为 60),直到成功为止。
8. 任何时候,收到 reconnect 包,应该将当前消息队列,`sn`等全部清空,然后回到第 1 步,否则可能会有消息错乱等各种问题。

Expand Down