Skip to content

fix(feishu): add WebSocket heartbeat config to prevent silent disconnection#46472

Closed
120106835 wants to merge 1 commit intoopenclaw:mainfrom
120106835:fix/feishu-ws-heartbeat
Closed

fix(feishu): add WebSocket heartbeat config to prevent silent disconnection#46472
120106835 wants to merge 1 commit intoopenclaw:mainfrom
120106835:fix/feishu-ws-heartbeat

Conversation

@120106835
Copy link
Copy Markdown

Problem

The Feishu WebSocket connection silently drops after extended idle periods. The connection object remains alive but stops receiving messages, causing the bot to miss all incoming messages until a gateway restart.

This is because createFeishuWSClient() does not pass wsConfig to Lark.WSClient, so no WebSocket-level keep-alive pings are sent.

Fix

Add wsConfig: { PingInterval: 30, PingTimeout: 5 } to the Lark.WSClient constructor in extensions/feishu/src/client.ts.

  • PingInterval: 30 — send a ping every 30 seconds
  • PingTimeout: 5 — consider the connection dead if no pong within 5 seconds

Testing

  • Applied this patch locally on OpenClaw 3.13
  • Monitored for 2+ hours with no silent disconnection (previously occurred within ~30 min of idle)
  • Verified via gateway.log that Feishu messages continue to be received after idle periods

Ref: larksuiteoapi/node-sdk#42354

…ection

Without wsConfig, the Feishu WebSocket connection silently drops after
extended idle periods — the connection object remains alive but stops
receiving messages. This causes the bot to miss all incoming messages
until a gateway restart.

Add PingInterval (30s) and PingTimeout (5s) to createFeishuWSClient()
to enable keep-alive pings on the WebSocket connection.

Ref: larksuiteoapi/node-sdk#42354
@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Mar 14, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 14, 2026

Greptile Summary

This PR fixes a silent WebSocket disconnection issue in the Feishu integration by adding a wsConfig with PingInterval: 30 and PingTimeout: 5 to the Lark.WSClient constructor in createFeishuWSClient(). Without this configuration, the Lark SDK sends no keep-alive pings, allowing idle connections to silently drop without the application noticing.

  • Fix is correct and targeted: The wsConfig is passed directly to the Lark.WSClient constructor alongside existing options; no other code paths are affected.
  • Values are reasonable defaults: A 30-second ping interval with a 5-second pong timeout is well within conventional WebSocket keep-alive norms and well within the interval.
  • No configurability: The heartbeat values are hard-coded. Unlike the existing httpTimeoutMs (which supports env-var and per-account overrides), there's no way to tune PingInterval or PingTimeout without a code change. This is a minor operational concern — in very high-latency or constrained environments, a 5-second PingTimeout could cause spurious reconnects — but it's not a correctness issue for typical deployments.
  • No test coverage included: The PR does not add or update unit tests for createFeishuWSClient. Given that the function just constructs and returns a Lark.WSClient, this is low risk, but a test asserting that the resulting client carries the expected wsConfig would make the fix more regression-proof.

Confidence Score: 5/5

  • This PR is safe to merge — it makes a small, well-scoped addition to fix a real production issue with no side effects on existing functionality.
  • The change touches a single constructor call, adding a well-documented SDK configuration option. The values chosen are sensible defaults, the fix directly addresses the described problem, and the author verified it with 2+ hours of idle-period testing. No critical logic, type, or security issues found.
  • No files require special attention.

Last reviewed commit: f8a9cbc

@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 28, 2026

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close this PR as superseded by merged maintainer PR #72411. Current main already carries the Feishu-owned heartbeat constructor option, regression coverage, and a broader reconnect/backoff repair, while #72411 explicitly credited this PR’s contribution. The one-file diff here no longer adds useful code to main.

Best possible solution:

Close this PR as superseded by #72411. Keep the current Feishu-owned heartbeat/reconnect implementation on main, and open a new focused Feishu issue or PR only if live testing shows a remaining disconnect problem under the pinned Lark SDK.

What I checked:

  • Superseding maintainer PR: GitHub API shows fix(feishu): repair WebSocket reconnect and heartbeat config #72411 was merged on 2026-04-28, and its body explicitly says it carries forward @120106835's equivalent heartbeat wsConfig fix from this PR along with the Feishu reconnect repair. (d93e6f61580a)
  • Current heartbeat implementation: Current main defines FEISHU_WS_CONFIG with PingInterval 30 and PingTimeout 3, then passes it as wsConfig to the Feishu Lark WSClient constructor. (extensions/feishu/src/client.ts:18, 5de284c2e30f)
  • Regression test coverage: The Feishu client test now asserts that createFeishuWSClient passes the heartbeat wsConfig defaults to Lark.WSClient. (extensions/feishu/src/client.test.ts:347, 5de284c2e30f)
  • Broader reconnect repair: Current main wraps Feishu WebSocket startup in a monitor-owned retry loop, awaits wsClient.start({ eventDispatcher }), cleans up failed clients, and backs off before retrying. (extensions/feishu/src/monitor.transport.ts:173, 5de284c2e30f)
  • Changelog credit: The 2026.4.27 changelog entry describes the Feishu WebSocket startup retry/heartbeat-default work and thanks @120106835 along with the other source PR authors. The latest published release in the supplied context is still v2026.4.26, so no fixed release is claimed. (CHANGELOG.md:283, 5de284c2e30f)
  • Security review of this PR diff: The supplied PR diff only adds a wsConfig object literal to the existing Feishu WSClient constructor options. It does not touch workflows, dependency sources, lockfiles, install/build/release scripts, package publishing metadata, secrets handling, or downloaded/executed artifacts. (extensions/feishu/src/client.ts:235, f8a9cbc5c7d5)

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5de284c2e30f; fix evidence: commit d93e6f61580a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant