openclaw - 💡(How to fix) Fix Discord WebSocket silently drops — messages not delivered to gateway [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75660Fetched 2026-05-02 05:32:08
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
2
Timeline (top)
mentioned ×2subscribed ×2closed ×1commented ×1

The Discord WebSocket connection silently disconnects, causing the gateway to stop receiving inbound messages (including @mentions). No error is logged, no reconnect is triggered — the connection just goes dead.

Error Message

The Discord WebSocket connection silently disconnects, causing the gateway to stop receiving inbound messages (including @mentions). No error is logged, no reconnect is triggered — the connection just goes dead. No WebSocket error, close, or reconnect events appear in logs between 09:13 and 09:29.

  • If reconnect fails, an error should be logged

Root Cause

The Discord WebSocket connection silently disconnects, causing the gateway to stop receiving inbound messages (including @mentions). No error is logged, no reconnect is triggered — the connection just goes dead.

Fix Action

Fix / Workaround

Current Workaround

Code Example

09:11 — discord-auto-reply preflight fires (skip: no-mention) ✅ working
09:13 — discord-auto-reply preflight fires (skip: no-mention) ✅ working
09:26 — user @mentions bot in #general — ZERO log entries ❌ dead
09:27 — user @mentions bot again — ZERO log entries ❌ dead
09:28 — user @mentions bot again — ZERO log entries ❌ dead
09:29 — manual gateway restart fixes it
RAW_BUFFERClick to expand / collapse

Summary

The Discord WebSocket connection silently disconnects, causing the gateway to stop receiving inbound messages (including @mentions). No error is logged, no reconnect is triggered — the connection just goes dead.

Environment

  • OpenClaw version: 2026.4.15 (041266a)
  • OS: macOS (Apple Silicon), residential internet
  • Discord.js via @openclaw/discord plugin
  • Config: requireMention: true, groupPolicy: allowlist

Observed Behavior

This has occurred on two consecutive days (April 30 and May 1, 2026):

  1. Discord integration works normally — messages arrive, discord-auto-reply logs preflight checks
  2. At some point, the WebSocket silently dies
  3. New messages from Discord (including direct @bot mentions) produce zero log entries — they never reach the preflightDiscordMessage handler
  4. The gateway process remains running and responsive on other channels (webchat works fine)
  5. The message tool can still send to Discord (REST API works), but receiving is dead
  6. Only fix is a full gateway restart, which re-establishes the WebSocket

Evidence from Logs (May 1, 2026)

09:11 — discord-auto-reply preflight fires (skip: no-mention) ✅ working
09:13 — discord-auto-reply preflight fires (skip: no-mention) ✅ working
09:26 — user @mentions bot in #general — ZERO log entries ❌ dead
09:27 — user @mentions bot again — ZERO log entries ❌ dead
09:28 — user @mentions bot again — ZERO log entries ❌ dead
09:29 — manual gateway restart fixes it

No WebSocket error, close, or reconnect events appear in logs between 09:13 and 09:29.

Expected Behavior

  • Discord.js should detect the dropped connection via its internal heartbeat
  • Auto-reconnect should fire and re-establish the WebSocket
  • If reconnect fails, an error should be logged

Suspected Cause

Silent WebSocket disconnect, likely due to:

  • NAT timeout on residential connection dropping the TCP session
  • Discord gateway heartbeat ACK not being checked aggressively enough
  • discord.js shardDisconnect / shardError events may not be firing

Current Workaround

A cron-based watchdog (every 15 min) that checks Discord responsiveness and auto-restarts the gateway if unresponsive.

Suggested Fix

  1. Hook into discord.js shardDisconnect, shardError, shardReconnecting events and log them
  2. Consider a more aggressive heartbeat check or periodic ping to detect dead connections faster
  3. If the shard goes unresponsive for >2 minutes, force a reconnect rather than waiting for the library's internal detection

Impact

High — this makes the bot appear offline/unresponsive to users on Discord, which is the primary interaction channel. Has occurred on 2 of 2 consecutive days observed.

extent analysis

TL;DR

Implementing a more aggressive heartbeat check and logging discord.js shard events may help detect and recover from silent WebSocket disconnects.

Guidance

  • Hook into discord.js shardDisconnect, shardError, and shardReconnecting events to log potential issues and improve visibility into connection state.
  • Consider implementing a periodic ping or more aggressive heartbeat check to detect dead connections faster, potentially forcing a reconnect if the shard is unresponsive for an extended period.
  • Review the current cron-based watchdog workaround and assess whether a more integrated solution using discord.js events can provide more reliable and timely detection of connectivity issues.
  • Investigate the NAT timeout on the residential connection and its potential impact on the TCP session to determine if adjustments can be made to prevent silent disconnects.

Example

client.on('shardDisconnect', (shardId, payload) => {
  console.log(`Shard ${shardId} disconnected: ${payload}`);
});

client.on('shardError', (shardId, error) => {
  console.log(`Shard ${shardId} error: ${error}`);
});

client.on('shardReconnecting', (shardId) => {
  console.log(`Shard ${shardId} reconnecting`);
});

Notes

The suggested fix and guidance are based on the provided information and may require further refinement or additional logging to fully resolve the issue. The residential connection's NAT timeout and its interaction with the Discord gateway heartbeat may also need to be investigated further.

Recommendation

Apply workaround: Implementing a more aggressive heartbeat check and logging discord.js shard events can help detect and recover from silent WebSocket disconnects, providing a more reliable and responsive bot experience for users.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Discord WebSocket silently drops — messages not delivered to gateway [1 comments, 2 participants]