openclaw - 💡(How to fix) Fix WhatsApp: Backfill missed messages after reconnection [3 comments, 2 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#50093Fetched 2026-04-08 00:59:14
View on GitHub
Comments
3
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×3subscribed ×1
  • WhatsApp Web protocol does support message history on session reconnect in some scenarios
  • The messagesHandled: 0 counter in the web-heartbeat logs confirms messages aren't being received during/after the outage
  • 503 errors appear as: WhatsApp Web connection closed (status 503). Retry 1/12
  • Even a short backfill window (e.g. last 2 hours on reconnect) would address the majority of cases

Root Cause

  • WhatsApp Web protocol does support message history on session reconnect in some scenarios
  • The messagesHandled: 0 counter in the web-heartbeat logs confirms messages aren't being received during/after the outage
  • 503 errors appear as: WhatsApp Web connection closed (status 503). Retry 1/12
  • Even a short backfill window (e.g. last 2 hours on reconnect) would address the majority of cases

Fix Action

Workaround

Currently none — missed group messages are unrecoverable through the log workaround.

RAW_BUFFERClick to expand / collapse

Feature Request

Problem

When the WhatsApp Web connection drops (e.g. 503 errors) and reconnects, messages sent to monitored groups during the outage window are never delivered or logged. The gateway reconnects successfully but the missed messages are silently lost.

This is particularly impactful for group chats where periodic summarization is being done via the log workaround (searching /tmp/openclaw/openclaw-YYYY-MM-DD.log for "2": "inbound message" entries with a known group JID).

Expected Behavior

After reconnection, the gateway should request missed messages from WhatsApp Web for any active monitored chats, at minimum for the gap period since last successful connection.

Current Behavior

Connection drops silently lose all group messages sent during the outage. The reconnected session starts fresh with no backfill.

Context

  • WhatsApp Web protocol does support message history on session reconnect in some scenarios
  • The messagesHandled: 0 counter in the web-heartbeat logs confirms messages aren't being received during/after the outage
  • 503 errors appear as: WhatsApp Web connection closed (status 503). Retry 1/12
  • Even a short backfill window (e.g. last 2 hours on reconnect) would address the majority of cases

Workaround

Currently none — missed group messages are unrecoverable through the log workaround.

extent analysis

Fix Plan

To address the issue of lost messages during WhatsApp Web connection outages, we will implement a message backfill mechanism. This involves modifying the gateway to request missed messages from WhatsApp Web after a successful reconnection.

Steps:

  • Modify the WhatsApp Web connection handler to detect when a connection is reestablished after an outage.
  • Upon reconnection, send a request to WhatsApp Web to fetch messages for the duration of the outage.
  • Implement a queue to store the fetched messages and process them as if they were received in real-time.

Example Code (Python):

import datetime
import time

# Assume 'whatsapp_web' is an object representing the WhatsApp Web connection
def reconnect_handler(whatsapp_web):
    # Calculate the outage duration
    outage_start = whatsapp_web.last_disconnection_time
    outage_end = datetime.datetime.now()
    outage_duration = (outage_end - outage_start).total_seconds() / 60  # in minutes

    # Request missed messages from WhatsApp Web
    missed_messages = whatsapp_web.fetch_messages(outage_start, outage_end)

    # Process the fetched messages
    for message in missed_messages:
        process_message(message)

def fetch_messages(self, start_time, end_time):
    # Implement the logic to fetch messages from WhatsApp Web using the WhatsApp Web API
    # This may involve sending a request to the WhatsApp Web API with the start and end times
    pass

def process_message(self, message):
    # Implement the logic to process the message as if it were received in real-time
    pass

Verification

To verify that the fix worked, monitor the gateway logs for messages received during the outage period after a reconnection. The messagesHandled counter in the web-heartbeat logs should increment correctly, indicating that missed messages are being received and processed.

Extra Tips

  • Consider implementing a configurable backfill window to limit the number of messages fetched upon reconnection.
  • Ensure that the message processing logic can handle duplicate messages, in case WhatsApp Web returns messages that were already processed before the outage.

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