Skip to content

Feature: configurable staleEventThresholdMs for channel health monitor #52717

Description

@braminatorh

Problem

The WhatsApp channel health monitor restarts the socket when no events arrive for >30 minutes (staleEventThresholdMs defaults to 1,800,000ms). During idle periods (e.g., nighttime), this causes ~38 unnecessary socket restarts per day.

Root Cause

In gateway-cli-*.js, resolveTimingPolicy() falls back to 18e5 (30min) when deps.timing?.staleEventThresholdMs is undefined. The main health monitor call site (startChannelHealthMonitor()) only passes channelManager and checkIntervalMs — no timing object.

Impact

  • ~38 restarts/day (1-2/hour), evenly distributed
  • 0 message delivery failures observed (restarts are seamless, 2-5s reconnect)
  • Cosmetic log noise, unnecessary reconnection churn

Requested Change

Expose staleEventThresholdMs as a configurable option, e.g.:

{
  "gateway": {
    "channelHealthCheckMinutes": 5,
    "channelHealthMonitor": {
      "staleEventThresholdMs": 7200000
    }
  }
}

Suggested default: 2 hours (7,200,000ms) for long-socket channels like WhatsApp.

Environment

  • OpenClaw 2026.3.13
  • WhatsApp channel (Baileys/WWebJS)
  • Ubuntu 24.04 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions