会话错误
会话级错误通过 session.error 事件发送。
AUTH_INVALID
ticket、token 或认证信息无效时发送。
json
{
"type": "event",
"topic": "session.error",
"data": {
"code": "AUTH_INVALID",
"message": "Authentication credentials are invalid."
}
}AUTH_EXPIRED
access token 过期时,WebSocket session 会关闭。
如果服务在关闭前发送错误事件,可使用:
json
{
"type": "event",
"topic": "session.error",
"data": {
"code": "AUTH_EXPIRED",
"message": "Authentication token has expired."
}
}RATE_LIMITED
心跳、重连或请求频率过高时发送。
json
{
"type": "event",
"topic": "session.error",
"data": {
"code": "RATE_LIMITED",
"message": "Rate limit was exceeded."
}
}客户端处理
- 鉴权相关错误:重新获取 access token 或 wsTicket 后重连
- 限流错误:降低频率后重试
- 网络异常:使用指数退避重连
- 多次重连失败:记录日志并告警
