openclaw - 💡(How to fix) Fix WhatsApp: creds.json corruption on every reconnect + overly aggressive heartbeat timeout [1 comments, 1 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#58525Fetched 2026-04-08 02:01:36
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1locked ×1

Two related issues with the WhatsApp channel causing constant reconnect churn on headless/VPS deployments.

Error Message

warn web-session restored corrupted WhatsApp creds.json from backup warn web-heartbeat Message timeout detected - forcing reconnect warn gateway/channels/whatsapp/heartbeat No messages received in 97m - restarting connection

Root Cause

Two related issues with the WhatsApp channel causing constant reconnect churn on headless/VPS deployments.

Code Example

warn web-session restored corrupted WhatsApp creds.json from backup

---

warn web-heartbeat  Message timeout detected - forcing reconnect
warn gateway/channels/whatsapp/heartbeat  No messages received in 97m - restarting connection
RAW_BUFFERClick to expand / collapse

Summary

Two related issues with the WhatsApp channel causing constant reconnect churn on headless/VPS deployments.

Issue 1: creds.json repeatedly reported as corrupted on reconnect

Every time the WhatsApp connection drops and reconnects, the gateway logs:

warn web-session restored corrupted WhatsApp creds.json from backup

The file is immediately restored from backup and the connection succeeds, so it's self-healing — but it suggests a write-race condition where creds.json is being written partially during the reconnect cycle, causing the integrity check to fail before the backup is restored.

Issue 2: Heartbeat timeout too aggressive on idle connections

The heartbeat fires every 60 seconds checking for inbound messages. If no messages have been received in 30+ minutes, it forces a reconnect:

warn web-heartbeat  Message timeout detected - forcing reconnect
warn gateway/channels/whatsapp/heartbeat  No messages received in 97m - restarting connection

On a headless server where the assistant isn't actively chatting, this causes the WhatsApp connection to reconnect every ~60 seconds indefinitely. This creates a loop of: connect → idle for 60s → force reconnect → creds corruption warning → restore from backup → repeat.

Environment

  • OpenClaw 2026.3.28
  • Ubuntu 24.04.4 LTS (headless VPS / Linode)
  • WhatsApp channel, single account, DM allowlist mode

Expected Behavior

  • creds.json should not be reported as corrupted on normal reconnects
  • The heartbeat should not force a reconnect on idle connections where the WebSocket itself is healthy — or the idle threshold should be configurable

Suggested Fix

  1. For the creds corruption: use atomic writes (write to temp file, then rename) to prevent partial-write races
  2. For the heartbeat: add a config option like channels.whatsapp.heartbeatIdleTimeoutMs to control the threshold, or check WebSocket health separately from message receipt before forcing a reconnect

extent analysis

TL;DR

Implement atomic writes for creds.json and introduce a configurable heartbeatIdleTimeoutMs to prevent unnecessary reconnects.

Guidance

  • To address the creds.json corruption issue, consider using a temporary file for writing and then renaming it to prevent partial writes.
  • Introduce a configurable heartbeatIdleTimeoutMs option to allow for customization of the idle threshold before forcing a reconnect.
  • Verify the fix by monitoring the gateway logs for warn web-session restored corrupted WhatsApp creds.json from backup and warn web-heartbeat Message timeout detected - forcing reconnect messages after implementing the changes.
  • Test the WhatsApp connection under idle conditions to ensure the reconnect loop is broken.

Example

import os

# Atomic write example
def atomic_write(filename, content):
    temp_filename = filename + '.tmp'
    with open(temp_filename, 'w') as f:
        f.write(content)
    os.rename(temp_filename, filename)

# Usage
atomic_write('creds.json', 'new_content')

Notes

The provided guidance assumes that the issue is indeed caused by a write-race condition and an overly aggressive heartbeat timeout. The suggested fix may need to be adapted based on the specific implementation details of the WhatsApp channel and gateway.

Recommendation

Apply workaround: Implement atomic writes and introduce a configurable heartbeatIdleTimeoutMs option to prevent unnecessary reconnects. This approach allows for a more robust and customizable solution to the identified issues.

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