Skip to content

fix: stop OpenClawX Node token_missing reconnect storm on gateway restart#109

Merged
mithun50 merged 4 commits into
mainfrom
copilot/fix-openclaw-2026-warn-issue
Apr 5, 2026
Merged

fix: stop OpenClawX Node token_missing reconnect storm on gateway restart#109
mithun50 merged 4 commits into
mainfrom
copilot/fix-openclaw-2026-warn-issue

Conversation

Copilot AI commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

After updating to 2026.4.1, the OpenClawX Node component hammers the gateway with unauthenticated connections at near-350ms intervals, flooding logs with reason=token_missing warnings from client=OpenClawX Node remote=127.0.0.1.

Two independent bugs compound to cause this:

1. Token resolution misses the config file (root cause of token_missing)

NodeService._readGatewayToken() only checked prefs.nodeGatewayToken and prefs.dashboardUrl. GatewayService.start() nulls out dashboardUrl before restarting the gateway — so any Node connect attempt during startup finds no token and sends an unauthenticated frame.

Added openclaw.json as a third fallback, consistent with GatewayService._readTokenFromConfig() which already treats it as the source of truth:

// 3. Read directly from openclaw.json — the source of truth (#94).
final raw = await NativeBridge.readRootfsFile('root/.openclaw/openclaw.json');
if (raw != null) {
  final config = jsonDecode(raw) as Map<String, dynamic>;
  final token = config['gateway']?['auth']?['token'];
  if (token is String && token.isNotEmpty) return token;
}

2. Reconnect backoff always restarted from base delay (keeps the storm alive)

NodeWsService._doConnect() reset _reconnectAttempt = 0 on every successful TCP handshake. Since the gateway accepts the TCP connection then rejects auth and closes the socket, the attempt counter never grew — the exponential backoff (base 350ms, cap 8s) was permanently stuck at 350ms.

Removed the reset from _doConnect(). Added resetReconnectAttempt() and call it only from NodeService._onConnected() — after the gateway has accepted the full authenticated handshake. Fresh explicit connect() calls still reset to 0.

- Add openclaw.json config file as 3rd fallback in _readGatewayToken()
  so the node always finds the gateway auth token even when dashboardUrl
  was cleared before a gateway restart (root cause of token_missing loop)
- Fix reconnect backoff: remove _reconnectAttempt = 0 from _doConnect()
  so the exponential backoff actually grows when auth keeps failing;
  reset only on successful authenticated connection via resetReconnectAttempt()

Agent-Logs-Url: https://github.com/mithun50/openclaw-termux/sessions/2f5ef8ee-b8bf-4ee1-ab15-ba2a1603670c

Co-authored-by: mithun50 <[email protected]>
Copilot AI changed the title [WIP] Fix warning issue after updating to OpenClaw 2026.4.1 fix: stop OpenClawX Node token_missing reconnect storm on gateway restart Apr 5, 2026
Copilot AI requested a review from mithun50 April 5, 2026 08:28
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

Build Successful

Version: v1.8.7

Download APKs

Architecture Download
arm64-v8a (recommended) OpenClaw-v1.8.7-arm64-v8a.apk
armeabi-v7a (32-bit) OpenClaw-v1.8.7-armeabi-v7a.apk
x86_64 (emulator) OpenClaw-v1.8.7-x86_64.apk
Universal (all ABIs) OpenClaw-v1.8.7-universal.apk
App Bundle (Play Store) OpenClaw-v1.8.7.aab

Download from Actions Artifacts


Built from de96904 by GitHub Actions

@mithun50

mithun50 commented Apr 5, 2026

Copy link
Copy Markdown
Owner

@copilot do smallest version bump

Copilot AI commented Apr 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot do smallest version bump

Done in commit 2fa8fef. Bumped 1.8.61.8.7 across flutter_app/lib/constants.dart, flutter_app/pubspec.yaml (now 1.8.7+18), and package.json.

Copilot AI requested a review from mithun50 April 5, 2026 08:35
@mithun50
mithun50 marked this pull request as ready for review April 5, 2026 08:35
@mithun50
mithun50 merged commit 2a523ba into main Apr 5, 2026
3 checks passed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fault after updating to OpenClaw (2026.4.1) - LOOK !

2 participants