Skip to content

Discord gateway websocket flapping on WSL2 causes silent inbound message loss #989

Description

@karkarl

Title: Discord gateway websocket flapping on WSL2 causes silent inbound message loss

Environment:

  • Host: WSL2 (Windows), KAREN-DEVBOX
  • OS: Linux 6.18.33.2-microsoft-standard-WSL2 (x64)
  • OpenClaw: CLI & Gateway 2026.6.10
  • Node: v22.22.0
  • Channel: Discord (direct messages)

Summary:
On WSL2, the Discord gateway websocket disconnects abnormally every ~3–5 minutes. Messages (including text + photo attachments) sent during a drop/reconnect window are silently lost — never delivered to the agent session, no error surfaced to the user.

Impact:
User sends messages that appear to send on the Discord client side but never reach the bot. No error, no retry, no notice. Confirmed via sessions_history that dropped messages have zero trace in the session record. Happened 3+ times in one session, including a batch with photo attachments.

Evidence (single day, /tmp/openclaw/openclaw-2026-07-14.log):

  • 66 total websocket closures
  • Breakdown: 38× code 1006 (abnormal), 4× 1000, 2× 1001
  • Zero RESUME/READY/reconnect-success markers logged
  • Closures roughly every 3–5 min, all day, e.g. 08:05, 08:09, 08:18, 08:22, 08:26, 08:28, 08:34…

Suspected root cause:
WSL2's virtual NIC/NAT layer drops long-lived idle connections; Discord's persistent gateway websocket is killed repeatedly. On reconnect the session appears to re-IDENTIFY rather than cleanly RESUME (no RESUME markers observed), so events missed during the gap are not replayed → permanent message loss.

Expected behavior:

  • On gateway reconnect, the client should RESUME and replay missed events where possible.
  • Inbound messages that fail to reach the agent should surface an error/retry rather than silently vanish.
  • Consider TCP keepalive defaults / connection-health handling tuned for NAT'd environments like WSL2.

Workarounds under investigation:

  • WSL2 TCP keepalive sysctls (tcp_keepalive_time, etc.)
  • WSL2 networkingMode=mirrored
  • wsl --update

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Status
    Connection and Pairing

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions