Skip to content

[Bug] WhatsApp 499 reconnection loop: inactivity timer not reset after successful reconnect #62258

@ArtemioPadilla

Description

@ArtemioPadilla

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

  1. Connect WhatsApp Web via OpenClaw gateway
  2. Wait for a period with no inbound messages (typically 2-6 hours)
  3. The health monitor triggers a reconnect due to inactivity
  4. After successful reconnect, the timer still shows the old lastMessageAt value
  5. ~60 seconds later, the health monitor triggers another reconnect
  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    close:duplicateClosed as duplicatededupe:childDuplicate issue/PR child in dedupe cluster

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions