openclaw - 💡(How to fix) Fix WhatsApp: Persistent 408 session timeout loop — WebSocket keepalive not preventing server-side idle disconnect [1 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#63410Fetched 2026-04-09 07:54:04
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

WhatsApp gateway disconnects with status 408 every ~15-17 minutes in a persistent, metronomic loop. The connection auto-reconnects successfully each time, but the loop never stops and causes message delivery failures during disconnect windows.

Root Cause

Root Cause Hypothesis

Code Example

2026-04-08T01:45 | first drop
2026-04-08T02:01 | +16 min
2026-04-08T02:18 | +16 min
2026-04-08T02:34 | +15 min
2026-04-08T02:50 | +16 min
... (60+ drops over 17 hours, same interval)
RAW_BUFFERClick to expand / collapse

Summary

WhatsApp gateway disconnects with status 408 every ~15-17 minutes in a persistent, metronomic loop. The connection auto-reconnects successfully each time, but the loop never stops and causes message delivery failures during disconnect windows.

Environment

  • OpenClaw version: 2026.4.8 (9ece252)
  • macOS (arm64), Node v25.8.2
  • Two WhatsApp accounts on the same gateway (default + secondary)
  • Multi-Device protocol (Baileys)

Observed Behavior

The gateway drops with status 408 every ~15-17 minutes, consistently:

2026-04-08T01:45 | first drop
2026-04-08T02:01 | +16 min
2026-04-08T02:18 | +16 min
2026-04-08T02:34 | +15 min
2026-04-08T02:50 | +16 min
... (60+ drops over 17 hours, same interval)

Both accounts drop simultaneously, suggesting this is a server-side session-level idle timeout, not a network issue.

What Was Tried

  1. Gateway restarts — clears the loop temporarily, but it resumes within ~24 minutes.
  2. Reduced heartbeat interval — changed agents.defaults.heartbeat.every from 30m to 10m with a lightweight model (gemini-2.5-flash-lite). This generates WhatsApp traffic via the heartbeat reply. Did NOT prevent the 408 drops — they continued at the same ~16 min interval.
  3. web.heartbeatSeconds — confirmed the plugin is already sending WebSocket-level pings at 60s intervals. These pings are not preventing the server-side session timeout.

Root Cause Hypothesis

The WhatsApp Multi-Device protocol has a server-side session idle timer of approximately 15-16 minutes. If the OpenClaw/Baileys WebSocket layer is not sending a protocol-level keepalive that WhatsApp's servers recognize as "session activity" (distinct from a TCP-level ping), the server recycles the session with a 408.

The internal web-heartbeat module (logging messagesHandled, uptimeMs, lastInboundAt) appears to be a monitoring-only loop that does not transmit any data to WhatsApp's servers.

Suggested Fix

The Baileys WhatsApp plugin should send a protocol-level keepalive (e.g., a no-op IQ stanza or presence update) to WhatsApp's servers at an interval shorter than the server's idle timeout (~10-12 minutes). This is separate from the TCP WebSocket ping and must be a WhatsApp application-layer message that resets the server's session idle timer.

Impact

  • Auto-reconnect handles the drop cleanly (no data loss in most cases)
  • Messages sent during the ~2-4 second disconnect window fail with forbidden (outbound) or are silently dropped (inbound)
  • 60+ API calls burned over 17 hours due to reconnect cycles
  • Agents relying on WhatsApp for proactive alerts cannot reliably reach users during disconnect windows

extent analysis

TL;DR

Implement a protocol-level keepalive mechanism in the Baileys WhatsApp plugin to send a no-op IQ stanza or presence update at an interval shorter than the server's idle timeout.

Guidance

  • Investigate the Baileys WhatsApp plugin documentation to determine the best approach for sending a protocol-level keepalive message.
  • Consider implementing a keepalive interval of 10-12 minutes to prevent the server-side session idle timer from expiring.
  • Verify that the keepalive message is being sent successfully and that the server's session idle timer is being reset.
  • Monitor the gateway's behavior after implementing the keepalive mechanism to ensure that the 408 drops are no longer occurring.

Example

// Example of sending a presence update as a keepalive message
const presence = {
  type: 'available',
  lastSeen: Math.floor(Date.now() / 1000)
};
baileysPlugin.sendPresenceUpdate(presence);

Note: This example is hypothetical and may not be the actual implementation, as the Baileys WhatsApp plugin documentation is not provided.

Notes

The implementation of the keepalive mechanism may require modifications to the Baileys WhatsApp plugin or the OpenClaw gateway. It is essential to test and verify the solution to ensure that it resolves the issue without introducing new problems.

Recommendation

Apply a workaround by implementing a protocol-level keepalive mechanism in the Baileys WhatsApp plugin, as this is likely to resolve the issue without requiring a version upgrade.

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