openclaw - 💡(How to fix) Fix WhatsApp Web listener does not survive session logout - gateway breaks permanently until manual restart [2 comments, 3 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#49305Fetched 2026-04-08 00:56:44
View on GitHub
Comments
2
Participants
3
Timeline
10
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×8commented ×2

Error Message

  1. openclaw message send fails with the same error runtime.error('WhatsApp session logged out...');

Root Cause

Found in source at dist/channel-web-BZO9MGfW.js, around line 2120:

if (loggedOut) {
    runtime.error('WhatsApp session logged out...');
    await closeListener();
    break;  // EXITS THE RECONNECT LOOP PERMANENTLY
}

When loggedOut === true, the code:

  1. Calls closeListener() which sets setActiveWebListener(account.accountId, null)
  2. Breaks out of the reconnect loop entirely
  3. The gateway continues running but with no WhatsApp listener

After this, even a successful channels login doesn't help because:

  • The login runs in a separate CLI process
  • The gateway's main monitor loop has already exited via break
  • There's no mechanism for the gateway to re-enter the monitor loop after a successful relink

Fix Action

Workaround

Currently the only workaround is: openclaw gateway restart followed by openclaw channels login --channel whatsapp — but the session may logout again at any time, requiring repeated manual intervention.

Code Example

if (loggedOut) {
    runtime.error('WhatsApp session logged out...');
    await closeListener();
    break;  // EXITS THE RECONNECT LOOP PERMANENTLY
}
RAW_BUFFERClick to expand / collapse

Bug Description

When the WhatsApp Web session is logged out (due to phone-side disconnect, session conflict, or instability), the gateway's WhatsApp listener permanently stops and cannot be recovered without a full gateway restart + manual relink.

Environment

  • OpenClaw version: 2026.3.13 (61d171a)
  • OS: Windows 11 (Windows_NT 10.0.26200 x64)
  • Node: v24.13.1
  • Channel: WhatsApp (personal Web)

Steps to Reproduce

  1. Start gateway with WhatsApp Web linked and working
  2. Wait for a session logout event (happens intermittently)
  3. All proactive sends fail with: No active WhatsApp Web listener (account: default)
  4. openclaw channels status --probe reports linked, running, connected (stale status)
  5. openclaw message send fails with the same error
  6. openclaw channels login --channel whatsapp shows Linked! Credentials saved
  7. message send again — still fails. The gateway process doesn't pick up the new listener.
  8. Only a full openclaw gateway restart + channels login resolves it (temporarily).

Root Cause Analysis

Found in source at dist/channel-web-BZO9MGfW.js, around line 2120:

if (loggedOut) {
    runtime.error('WhatsApp session logged out...');
    await closeListener();
    break;  // EXITS THE RECONNECT LOOP PERMANENTLY
}

When loggedOut === true, the code:

  1. Calls closeListener() which sets setActiveWebListener(account.accountId, null)
  2. Breaks out of the reconnect loop entirely
  3. The gateway continues running but with no WhatsApp listener

After this, even a successful channels login doesn't help because:

  • The login runs in a separate CLI process
  • The gateway's main monitor loop has already exited via break
  • There's no mechanism for the gateway to re-enter the monitor loop after a successful relink

Additional Issues

  1. Stale status reporting: channels status --probe reports connected even when the listener is dead.
  2. Auto-reply vs proactive send divergence: Inbound messages and auto-replies continue working (via the web-inbound path), but proactive sends (message send, cron announces, subagent announces) fail because they call requireActiveWebListener().

Expected Behavior

  • After a logout event, the gateway should attempt to re-authenticate using stored credentials before giving up
  • If re-auth fails, it should enter a retry loop (with backoff) instead of permanently breaking
  • channels login from CLI should be able to inject a new listener into the running gateway process
  • channels status should accurately reflect the listener state

Impact

This bug breaks all proactive messaging:

  • Cron job delivery (email monitoring, scheduled reports)
  • Sub-agent announce delivery
  • CLI message send
  • Any feature that uses requireActiveWebListener()

Workaround

Currently the only workaround is: openclaw gateway restart followed by openclaw channels login --channel whatsapp — but the session may logout again at any time, requiring repeated manual intervention.

extent analysis

Fix Plan

To address the issue, we need to modify the reconnect loop to handle the loggedOut event without permanently exiting. We'll introduce a retry mechanism with backoff.

Step-by-Step Solution

  1. Modify the reconnect loop:

    • Remove the break statement when loggedOut is true.
    • Introduce a retry counter and a backoff mechanism.
  2. Implement retry logic:

    • After closeListener() is called, wait for a certain amount of time before attempting to reconnect.
    • Increase the wait time after each failed reconnect attempt.
  3. Update channels login to inject a new listener:

    • Modify the channels login command to notify the gateway process to restart the listener.
  4. Improve status reporting:

    • Update channels status --probe to accurately reflect the listener state.

Example Code Changes

// Modified reconnect loop
let retryCount = 0;
const maxRetries = 5;
const initialBackoff = 1000; // 1 second
const backoffMultiplier = 2;

if (loggedOut) {
    runtime.error('WhatsApp session logged out...');
    await closeListener();
    retryCount++;

    // Calculate backoff time
    const backoffTime = initialBackoff * Math.pow(backoffMultiplier, retryCount);

    // Wait before retrying
    await new Promise(resolve => setTimeout(resolve, backoffTime));

    // Retry if within max retries
    if (retryCount <= maxRetries) {
        // Attempt to reconnect
        // ...
    } else {
        // Handle max retries exceeded
        // ...
    }
}

// Update channels login to inject a new listener
// Assuming a function to restart the listener
function restartListener() {
    // Logic to restart the listener
}

// Call restartListener when channels login is executed
// ...

Verification

To verify the fix, follow these steps:

  1. Start the gateway with WhatsApp Web linked and working.
  2. Simulate a session logout event.
  3. Verify that the gateway attempts to reconnect after a short delay.
  4. Check that channels status --probe accurately reflects the listener state.
  5. Test proactive sends (e.g., openclaw message send) to ensure they work after a successful reconnect.

Extra Tips

  • Consider implementing a more robust backoff strategy, such as exponential backoff with jitter.
  • Add logging to track reconnect attempts and failures for easier debugging.
  • Review the channels login command to ensure it properly handles errors and edge cases.

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