Fix: Discord Messages Lost After WebSocket Reconnect
Sequence Gap After 1006/1005 Disconnect
The gateway reconnects to Discord, but messages and @mentions sent during the disconnection window are never delivered. This happens when the session is not properly resumed and Discord stops replaying missed events.
Discord's Gateway uses sequence numbers (s field) to track every event. After a disconnect, you have a short window to resume the session with the last known s value. If OpenClaw starts a fresh session instead of resuming, Discord does not send the events from the gap โ those @mentions are gone.
Next Step
Fix now, then reduce repeat incidents
If this issue keeps coming back, validate your setup in Doctor first, then harden your config.
Jump to Fix
What You See in Logs
The key line is session resumed? false. When this appears, Discord treated the reconnect as a new session and the sequence gap is unrecoverable. Events from the disconnection window are lost.
Fix A: Enable Session Resume
OpenClaw supports Discord Gateway session resume. Make sure it's enabled in your config and that the resume URL is being stored between restarts:
{
"channels": {
"discord": {
"gateway": {
"resumeOnReconnect": true,
"storeSessionState": true
}
}
}
}After updating config, restart and check logs for confirmation:
openclaw gateway restart && openclaw logs --follow | grep -i 'discord\\|resume\\|session'
You should see [discord] session resume available: true and after any reconnect: session resumed? true.
Fix B: Shorten the Reconnect Window
Discord only holds session state for approximately 60 seconds after a disconnect. If your gateway takes longer than that to reconnect, resume will fail even if it's enabled. Common causes of slow reconnects:
Long restart delay in systemd / PM2
Set RestartSec=2 in your service file, or set restart_delay: 1000 in PM2 config
Slow network recovery (VPN, container restart)
Use Docker --restart=unless-stopped and avoid cold-start delays
Health check waiting too long before reconnect
Reduce the gateway healthCheckInterval if available in your config
Fix C: Use Discord Gateway v10
Older gateway versions have weaker resume support. Gateway v10 has more reliable resume behavior and better handling of the RECONNECT opcode. Check which version OpenClaw is using and upgrade if needed:
{
"channels": {
"discord": {
"gateway": {
"version": 10
}
}
}
}Monitor for Disconnects
To see when disconnects happen and whether resumes succeed:
openclaw logs --follow | grep -E '(1006|1005|disconnect|resume|reconnect)'
Frequent 1006 disconnects often indicate a network stability issue rather than a gateway config problem. If you see more than 2โ3 per day, check your host network or consider moving to a more stable hosting environment.
Still Missing Messages?
If messages are still being lost even after enabling resume, run the Doctor for a full channel diagnostic:
Run the Doctor
Checks Discord gateway connectivity, session resume config, and intent settings.
Related Discord Issues
Other common Discord channel problems:
Fix It Faster With Our Tools
Did this guide solve your problem?