#discord || gateway websocket closed:1006
1 messages · Page 1 of 1 (latest)
这是 Discord Gateway 的 WS 连接被异常中断(1006):
1006= abnormal closure(没收到正常 close frame)- 常见原因是网络抖动、Discord 网关侧重连、代理/防火墙空闲超时
- 你日志里有
resume=true,说明它会话恢复重连;能马上连上通常不算致命问题
如果只是偶发,基本可忽略。
如果“每几秒就跳一次”,建议按这个顺序查:
- 先看版本(很关键)
pnpm openclaw --version - 看网关和频道探针
pnpm openclaw gateway status
pnpm openclaw channels status --probe - 如果走了代理,重点查 WS 超时/断连(
channels.discord.proxy) - 确认没有两个进程同时用同一个 Discord token
- 升级到最新版本后重启一次 gateway
相关文档:
- https://docs.openclaw.ai/channels/discord#troubleshooting
- https://docs.openclaw.ai/gateway/troubleshooting
- https://docs.openclaw.ai/start/faq
你可以把 pnpm openclaw --version 和 gateway status 贴出来,我帮你判断这是“正常抖动”还是“异常频繁掉线”。
mac@macdeMac-mini ~ % openclaw --version
OpenClaw 2026.4.2 (d74a122)
mac@macdeMac-mini ~ % openclaw gateway status
🦞 OpenClaw 2026.4.2 (d74a122)
I speak fluent bash, mild sarcasm, and aggressive tab-completion energy.
│
◇
Service: LaunchAgent (loaded)
File logs: /tmp/openclaw/openclaw-2026-04-05.log
Command: /usr/local/bin/node /Users/mac/.npm-global/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Service env: OPENCLAW_GATEWAY_PORT=18789
Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json
Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.
Runtime: running (pid 47132)
RPC probe: ok
Listening: 127.0.0.1:18789
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
看你贴的状态,网关本身是健康的(Runtime: running + RPC probe: ok),版本也不旧。
所以这个 discord gateway: Gateway websocket closed: 1006 大概率是:
- Discord 网关侧瞬时断开 / 网络抖动
- 然后客户端自动
resume=true续会话恢复
也就是:会跳,但能自动恢复,通常不算故障。
如果只是偶发,可以直接忽略。
如果是高频(比如几十秒一次甚至更快),再排查这几个点:
- 先确认只有一个 OpenClaw 进程在跑(避免同 token 抢连接)
pgrep -fal "openclaw.*gateway" - 跑一次 Discord 通道探针
openclaw channels status --probe - 若开了 VPN/代理,临时关掉测试(WS 很容易被中间层空闲超时踢掉)
- 看看是否伴随消息延迟/漏消息;如果没有实际影响,就当日志噪声处理
参考文档:
- https://docs.openclaw.ai/channels/discord#troubleshooting
- https://docs.openclaw.ai/gateway/troubleshooting
如果你愿意,我可以按你日志再帮你判断“正常抖动”还是“异常频繁重连”(贴 1~2 分钟连续日志就行)。
非常频繁,我有5个AGENT,基本上 50S左右,这些AGENT都会跳一次重连
这个信息很关键:“大约每 50 秒一次”。
这通常不是 Discord 正常抖动,更像下面两类问题之一:
- 中间层(VPN/代理/网络设备)在 ~60s 把 WS 干掉
- 有多个 gateway 进程/实例在抢同一个 Discord 连接
另外你说有 5 个 agent:
正确架构是 1 个 gateway + 多 agent 路由,不是 5 个独立 gateway 各自连 Discord。
先做这 3 个快速检查(最有效):
# 1) 看是否只跑了一个 gateway
pgrep -fal "openclaw.*gateway"
# 2) 看是否配置了 Discord 代理
openclaw config get channels.discord.proxy
# 3) 看系统代理环境变量
echo $HTTP_PROXY $HTTPS_PROXY $ALL_PROXY
如果第 1 条输出不止一个进程,先只留一个。
如果第 2/3 条有代理,先临时关掉代理/VPN 测 5 分钟(50s 周期通常会立刻消失)。
如果你愿意,贴这 3 条输出,我可以直接帮你判断是哪一类。
相关文档:https://docs.openclaw.ai/channels/discord#troubleshooting / https://docs.openclaw.ai/concepts/multi-agent
mac@macdeMac-mini ~ % pgrep -fal "openclaw.*gateway"
47132 openclaw-gateway NODE_USE_SYSTEM_CA=1 OPENCLAW_GATEWAY_PORT=18789 OPENCLAW_SYSTEMD_UNIT=openclaw-gateway.service OPENCLAW_SERVICE_VERSION=2026.3.28
mac@macdeMac-mini ~ % openclaw channels status --probe
🦞 OpenClaw 2026.4.2 (d74a122) — Deployed locally, trusted globally, debugged eternally.
│
◇
Gateway reachable.
- Discord baogongtou: enabled, configured, running, connected, in:10m ago, bot:@包工头, token:config, intents:content=limited, works
Tip: status --deep adds gateway health probes to status output (requires a reachable gateway).
mac@macdeMac-mini ~ %
这两条输出很有价值,已经排除了一大类问题:
- ✅ 只有一个 gateway 进程(不是多实例抢连接)
- ✅
channels status --probe显示 Discord 连接是可用的
所以现在最可疑的是 网络链路层(代理/VPN/防火墙)周期性踢 WS,其次是服务安装元数据有点旧(你进程里还有 OPENCLAW_SERVICE_VERSION=2026.3.28)。
建议按下面顺序做(很快):
# 1) 看是否用了 Discord 代理配置
openclaw config get channels.discord.proxy
# 2) 看系统代理环境变量
env | grep -Ei 'http_proxy|https_proxy|all_proxy|no_proxy'
如果有代理(配置或环境变量),先临时关闭代理/VPN测 5 分钟。
你这个“约 50s 一次”非常像中间层 timeout。
再做一次服务重装(顺便消除 service 版本残留):
openclaw gateway install --force
openclaw gateway restart
如果你愿意,我下一步可以按你日志做“1 分钟诊断模板”(直接 grep 出断线周期和是否 heartbeat timeout),基本能确定是不是网络层问题。
mac@macdeMac-mini ~ % openclaw config get channels.discord.proxy
🦞 OpenClaw 2026.4.2 (d74a122)
WhatsApp automation without the "please accept our new privacy policy".
Config path not found: channels.discord.proxy
mac@macdeMac-mini ~ % env | grep -Ei 'http_proxy|https_proxy|all_proxy|no_proxy'
mac@macdeMac-mini ~ %
很好,这两项已经把配置问题基本排除了(无 proxy 配置、无 env 代理、单 gateway)。
那现在我判断是:宿主机网络层/链路层导致的周期性 WS 断开(不是 OpenClaw 配置错)。
你这个“约 50s 周期”非常像连接被中间层定时踢掉。
再做两个最后验证:
# 1) 重装并重启服务(清掉旧 service 元信息)
openclaw gateway install --force
openclaw gateway restart
# 2) 前台跑 2~3 分钟抓详细网关日志
openclaw gateway stop
OPENCLAW_LOG_LEVEL=debug openclaw gateway --verbose --ws-log compact
重点看是否反复出现这些字样:
Gateway websocket closed: 1006Gateway reconnect scheduled ... (resume=true)Gateway forcing fresh IDENTIFY after ... failed resume attempts
如果第 2 步仍然稳定 50s 一次,那基本可以定性为网络路径问题(系统级代理/TUN/VPN/防火墙/运营商链路),不是你 bot token 或 agent 配置问题。
你把第 2 步里连续 1 分钟日志贴上来,我可以直接帮你做最终结论;如果确认是这个,我们再给你最稳妥的落地方案(比如固定网络出口或迁到 VPS)。
20:25:18+08:00 [agent/embedded] embedded run prompt end: runId=6c21466e-c3df-47a7-a307-b18aab650a3c sessionId=6c21466e-c3df-47a7-a307-b18aab650a3c durationMs=3512
20:25:18+08:00 [diagnostic] session state: sessionId=6c21466e-c3df-47a7-a307-b18aab650a3c sessionKey=agent:baogongtou:cron:fa54f51e-a48a-4eb0-9d82-245996529ecc prev=processing new=idle reason="run_completed" queueDepth=0
20:25:18+08:00 [diagnostic] run cleared: sessionId=6c21466e-c3df-47a7-a307-b18aab650a3c totalActive=0
20:25:18+08:00 [ws] ⇄ res ✓ sessions.list 19ms id=a0188355…ea78
20:25:18+08:00 [agent/embedded] embedded run done: runId=6c21466e-c3df-47a7-a307-b18aab650a3c sessionId=6c21466e-c3df-47a7-a307-b18aab650a3c durationMs=9128 aborted=false
20:25:18+08:00 [diagnostic] lane task done: lane=nested durationMs=9130 active=0 queued=0
20:25:18+08:00 [diagnostic] lane task done: lane=session:agent:baogongtou:cron:fa54f51e-a48a-4eb0-9d82-245996529ecc durationMs=9136 active=0 queued=0
20:25:18+08:00 [ws] → event cron seq=44 clients=1 dropIfSlow=true
20:25:18+08:00 [ws] ⇄ res ✓ channels.status 1ms id=dc8b1146…2308
20:25:18+08:00 [ws] ⇄ res ✓ cron.status 5ms id=cc8eea4f…aadf
20:25:18+08:00 [ws] ⇄ res ✓ cron.list 7ms id=736fc1cb…cfc8
20:25:18+08:00 [ws] ⇄ res ✓ cron.runs 2ms id=8c9796be…6779
20:25:21+08:00 [ws] → event tick seq=45 clients=1 dropIfSlow=true
20:25:51+08:00 [ws] → event tick seq=46 clients=1 dropIfSlow=true
20:25:53+08:00 [ws] → event health seq=47 clients=1 presenceVersion=2 healthVersion=8
20:25:59+08:00 [ws] ⇄ res ✓ node.list 1ms id=c91a52a0…e5fb
20:26:04+08:00 discord gateway metrics: {"latency":315,"uptime":300345,"reconnects":1,"zombieConnections":0,"messagesReceived":13,"messagesSent":9,"errors":0}
20:26:21+08:00 [ws] → event tick seq=48 clients=1 dropIfSlow=true
你这段日志里其实 没有发生重连风暴,关键点是:
discord gateway metrics: ... "uptime":300345, "reconnects":1uptime≈ 300 秒(已经稳定连了 5 分钟)reconnects:1= 这段时间只重连过 1 次20:25:21 / 20:25:51 / 20:26:21 [ws] → event tick- 这是 OpenClaw 的内部 tick 心跳事件(约 30s 一次),不是 Discord 重连
所以你看到“在跳”的那部分,多半是 tick/health 正常日志,不是掉线。
可以再快速自检一次(只看真正掉线行):
grep "discord gateway: Gateway websocket closed: 1006" /tmp/openclaw/openclaw-$(date +%F).log | tail -20