openclaw - 💡(How to fix) Fix WebSocket ping/pong heartbeat config to prevent browser idle disconnects [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#51010Fetched 2026-04-08 01:05:36
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Timeline (top)
commented ×1

Root Cause

No WebSocket ping/pong heartbeat is configured in the Gateway. Browsers aggressively close idle WebSocket connections, especially on macOS. Without server-side ping/pong, the connection appears "alive" to the Gateway but is actually dead on the browser side.

Code Example

{
  "gateway": {
    "wsConfig": {
      "PingInterval": 30,
      "PingTimeout": 5
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Control UI WebSocket connections repeatedly disconnect with code 1001 ("Going Away") originating from the client (browser), not the server. This is a known browser behavior - closing idle WebSocket connections after a certain threshold.

Flapping episodes: ~10-70 minutes of stable connection, then rapid disconnect/reconnect cycles for 1-6 minutes. This causes:

  • RPC calls during flapping window to fail silently (client never receives response)
  • Poor user experience even on transient network hiccups
  • "Reconnected" state with no visibility into message delivery gap

Root Cause

No WebSocket ping/pong heartbeat is configured in the Gateway. Browsers aggressively close idle WebSocket connections, especially on macOS. Without server-side ping/pong, the connection appears "alive" to the Gateway but is actually dead on the browser side.

Proposed Fix

Add a configurable wsConfig section to the Gateway config (e.g. in openclaw.json):

{
  "gateway": {
    "wsConfig": {
      "PingInterval": 30,
      "PingTimeout": 5
    }
  }
}

Alternatively, enable this by default in the Control UI since the user has no way to configure this themselves.

This is similar to the fix in PR #46472 which addressed a Feishu WebSocket heartbeat issue.

Additional Context

  • Gateway mode: local loopback with token auth
  • Control UI accessed via http://127.0.0.1:PORT/
  • No gateway service restart required - issue is on the client connection side
  • Control UI eventually auto-recovers after flapping episode ends

extent analysis

Fix Plan

To resolve the issue of WebSocket connections repeatedly disconnecting, we need to implement a WebSocket ping/pong heartbeat mechanism. Here are the steps:

  • Add a wsConfig section to the Gateway configuration file (openclaw.json) with the following settings:
{
  "gateway": {
    "wsConfig": {
      "PingInterval": 30,
      "PingTimeout": 5
    }
  }
}
  • Alternatively, enable the WebSocket ping/pong heartbeat by default in the Control UI.

Example Code

To implement the WebSocket ping/pong heartbeat, you can use the following example code:

// Set up WebSocket connection with ping/pong heartbeat
const ws = new WebSocket('ws://127.0.0.1:PORT/', {
  pingInterval: 30000, // 30 seconds
  pingTimeout: 5000, // 5 seconds
});

Verification

To verify that the fix worked, you can:

  • Monitor the WebSocket connection for disconnections and reconnects
  • Check the browser console for any error messages related to WebSocket connections
  • Test the Control UI with simulated network hiccups to ensure that the connection remains stable

Extra Tips

  • Make sure to adjust the PingInterval and PingTimeout values according to your specific use case and network conditions.
  • Consider implementing additional error handling and logging mechanisms to detect and diagnose any issues related to WebSocket connections.

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

openclaw - 💡(How to fix) Fix WebSocket ping/pong heartbeat config to prevent browser idle disconnects [1 comments, 2 participants]