Bug Description
The WhatsApp gateway enters an infinite disconnect/reconnect loop (status 499) when no inbound messages are received for an extended period. The health monitor detects "no messages in X min" and triggers a reconnection, but the inactivity timer is not reset after a successful reconnect. This causes the timer to immediately trigger another reconnect ~60s later, creating an infinite loop.
Reproduction
- Connect WhatsApp Web via OpenClaw gateway
- Wait for a period with no inbound messages (typically 2-6 hours)
- The health monitor triggers a reconnect due to inactivity
- After successful reconnect, the timer still shows the old
lastMessageAt value
- ~60 seconds later, the health monitor triggers another reconnect
- Loop continues indefinitely until an actual inbound message arrives
Evidence
Over ~24 hours, we observed 202 disconnect/reconnect events in distinct bursts:
- Sat Apr 5, 08:31–09:59 UTC → 85 events
- Sat Apr 5, 11:00–15:59 UTC → 64 events
- Sat Apr 5, 20:00–Sun 07:43 UTC → 53 events
Gateway logs show the pattern:
[whatsapp] No messages received in 118m - restarting connection
[whatsapp] Web connection closed (status 499). Retry 1/12 in 2.16s…
[whatsapp] Listening for personal WhatsApp inbound messages.
[whatsapp] No messages received in 119m - restarting connection ← timer NOT reset
Collateral Damage
- Cron job deliveries fail with "No active WhatsApp Web listener"
- Pending delivery entries stuck in backoff
- Agent runs fail during the reconnect window
Workaround
Disabling the health monitor stops the loop but loses legitimate disconnect detection:
{
"channels": {
"whatsapp": {
"healthMonitor": { "enabled": false }
}
}
}
Expected Behavior
After a successful reconnect, lastMessageAt (or equivalent inactivity timer) should be reset to the current timestamp, preventing the health monitor from immediately triggering another reconnect.
Environment
- OpenClaw latest (d74a122)
- WhatsApp channel (personal, linked device)
- Ubuntu ARM64 (t4g.2xlarge)
- Node v22.22.2
Bug Description
The WhatsApp gateway enters an infinite disconnect/reconnect loop (status 499) when no inbound messages are received for an extended period. The health monitor detects "no messages in X min" and triggers a reconnection, but the inactivity timer is not reset after a successful reconnect. This causes the timer to immediately trigger another reconnect ~60s later, creating an infinite loop.
Reproduction
lastMessageAtvalueEvidence
Over ~24 hours, we observed 202 disconnect/reconnect events in distinct bursts:
Gateway logs show the pattern:
Collateral Damage
Workaround
Disabling the health monitor stops the loop but loses legitimate disconnect detection:
{ "channels": { "whatsapp": { "healthMonitor": { "enabled": false } } } }Expected Behavior
After a successful reconnect,
lastMessageAt(or equivalent inactivity timer) should be reset to the current timestamp, preventing the health monitor from immediately triggering another reconnect.Environment