-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
Discord: WebSocket 1005/1006 disconnects with failing resume logic and unbounded backoff #13688
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Discord WebSocket connections repeatedly drop (codes 1005/1006), resume attempts fail, and exponential backoff grows without bound, leaving the bot offline for 30+ minutes. DMs are silently lost during downtime.
Environment
- OpenClaw version: 2026.1.24-3
- OS: macOS (Darwin 25.3.0, arm64)
- Channel: Discord Bot API via channels.discord.js
- Network: Residential broadband (stable, other channels working)
Expected Behavior
- Discord gateway reconnects within 5-10 seconds of disconnect
- Resume session or fresh IDENTIFY on resume failure
- Messages queued/delivered after reconnection
Actual Behavior
- WebSocket closes with 1005/1006 (abnormal closure)
- Resume attempts fail repeatedly
- Backoff escalates: 1s → 2s → 4s → 8s → 16s → ...
- "connection stalled: no HELLO received within 30000ms"
- Bot offline for 30+ minutes
Logs
2026-01-27T13:49:49.752Z [discord] gateway: WebSocket connection closed with code 1005
2026-01-27T13:50:19.238Z [discord] gateway: Attempting resume with backoff: 1000ms
2026-01-27T13:50:19.526Z [discord] gateway: WebSocket connection closed with code 1005
2026-01-27T14:02:43.531Z [discord] connection stalled: no HELLO received within 30000ms
2026-01-27T14:02:44.069Z [discord] gateway: WebSocket connection closed with code 1006
Configuration
{
"channels": {
"discord": {
"enabled": true,
"dm": { "policy": "open", "allowFrom": ["*"] }
}
}
}No retry or gateway reconnect configuration options available for WebSocket-level issues.
Comparison: WhatsApp Has Gateway Reconnect Config
WhatsApp channel supports explicit reconnection tuning:
{
"web": {
"reconnect": {
"initialMs": 2000,
"maxMs": 120000,
"factor": 1.4,
"jitter": 0.2
}
}
}Request: Add similar channels.discord.gateway.reconnect configuration.
Potential Root Causes
- Resume session expiration - Discord invalidates sessions after ~5 minutes of disconnect
- No bounded backoff - Exponential backoff exceeds session validity window
- No fallback to fresh IDENTIFY - Resume failures don't trigger new gateway session
- No keepalive tuning - Cannot configure HEARTBEAT interval or ACK timeout
Proposed Solutions
- Add gateway reconnect config (like WhatsApp)
- Cap exponential backoff at 15-30 seconds
- Fast-fail resume after 3 attempts → new IDENTIFY
- Add keepalive config (HEARTBEAT interval, timeout)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.