Skip to content

WhatsApp Baileys: idle message timer doesn't reset on reconnect, causing infinite 499 loop #61326

@LindaJets

Description

@LindaJets

Bug Description

The WhatsApp Baileys plugin has an idle message timer that triggers a connection restart when no messages are received for ~58-60 minutes. However, the timer does not reset on reconnect. This causes an infinite reconnection loop:

  1. No messages for ~58 min → plugin logs "No messages received in 58m - restarting connection"
  2. Connection closes with status 499, reconnects in ~2s
  3. Timer still counting from last real message (59m, 60m, 61m...)
  4. Immediately triggers another restart → infinite loop every ~60s

Impact

  • WhatsApp becomes completely unusable during the loop
  • Only fix is a full gateway restart (systemctl --user restart openclaw-gateway.service)
  • Recurs every time the bot goes idle for ~1 hour
  • Observed 5+ times over 3 days (Apr 2-5, 2026)

Logs

Apr 05 11:37:01 [whatsapp] No messages received in 58m - restarting connection
Apr 05 11:37:01 [whatsapp] Web connection closed (status 499). Retry 1/12 in 2.47s…
Apr 05 11:38:04 [whatsapp] No messages received in 59m - restarting connection
Apr 05 11:38:04 [whatsapp] Web connection closed (status 499). Retry 1/12 in 2.07s…
Apr 05 11:39:07 [whatsapp] No messages received in 60m - restarting connection
...continues indefinitely...

Environment

  • OpenClaw: 2026.4.1 (da64a97)
  • OS: Ubuntu Linux 6.8.0-90 x64
  • Node: v22.22.1
  • WhatsApp plugin: Baileys (personal linked number)

What does NOT fix it

  • channelStaleEventThresholdMinutes: 180 — this controls a different timer (OpenClaw health monitor), not the Baileys internal idle timer

Expected Fix

The idle message timer should reset to zero on successful reconnect. Alternatively, expose the timer threshold as a config option (e.g., messageIdleTimeoutMinutes) so it can be tuned or disabled.

Workaround

Restart the gateway service when the loop is detected. A keepalive cron sending a message every 50min also prevents it but is hacky.

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