openclaw - 💡(How to fix) Fix [Bug]: Chrome extension uses stale token for WebSocket relay connection despite correct token saved in options [3 comments, 2 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#50140Fetched 2026-04-08 00:58:44
View on GitHub
Comments
3
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×3

After saving the correct gateway token in the Chrome extension options page, the extension still initiates WebSocket connections to the relay using an old/stale token, resulting in a 403 error.

Error Message

After saving the correct gateway token in the Chrome extension options page, the extension still initiates WebSocket connections to the relay using an old/stale token, resulting in a 403 error. Error during WebSocket handshake: Unexpected response code: 403

Root Cause

After saving the correct gateway token in the Chrome extension options page, the extension still initiates WebSocket connections to the relay using an old/stale token, resulting in a 403 error.

Fix Action

Workaround

None found. Reloading the extension from chrome://extensions does not help.

Code Example

background.js:183 WebSocket connection to 'ws://127.0.0.1:18792/extension?token=<OLD_TOKEN>' failed: 
Error during WebSocket handshake: Unexpected response code: 403
RAW_BUFFERClick to expand / collapse

Bug type

Incorrect behavior (not a crash)

Summary

After saving the correct gateway token in the Chrome extension options page, the extension still initiates WebSocket connections to the relay using an old/stale token, resulting in a 403 error.

Steps to reproduce

  1. Install the OpenClaw Chrome extension (local unpacked version from node_modules/openclaw/assets/chrome-extension)
  2. Open the extension options page and enter the correct gateway token
  3. Save the settings
  4. Click the extension icon on any tab to attach
  5. Observe the background service worker console

Expected behavior

The extension should use the token saved in options for the WebSocket connection to the relay.

Actual behavior

The extension connects using an old/stale token:

background.js:183 WebSocket connection to 'ws://127.0.0.1:18792/extension?token=<OLD_TOKEN>' failed: 
Error during WebSocket handshake: Unexpected response code: 403

Even after updating the token in options and saving, the WebSocket request still uses the previous token. The relay correctly rejects it with 403.

Workaround

None found. Reloading the extension from chrome://extensions does not help.

OpenClaw version

2026.3.14 (built from source)

Operating system

macOS Darwin 25.3.0 (arm64)

Install method

Built from source (git)

Related issues

Possibly related to #41214 (relay lazy-start / browser node routing regression)

Additional information

  • Gateway token in openclaw.json: correct and verified working via curl
  • Relay reachable and authenticated via options page health check
  • Token mismatch only appears in the WebSocket connection initiated by the extension background script

extent analysis

Fix Plan

To resolve the issue of the Chrome extension using an old/stale token for WebSocket connections, follow these steps:

  • Update the background.js file to refresh the token after saving the settings:
    • Listen for changes to the token in the options page
    • Update the token stored in the background script
  • Ensure the WebSocket connection is initiated with the latest token

Example code changes:

// In options.js
chrome.storage.local.set({ gatewayToken: token });

// In background.js
chrome.storage.local.get('gatewayToken', (result) => {
  const token = result.gatewayToken;
  // Use the updated token for WebSocket connections
  const wsUrl = `ws://127.0.0.1:18792/extension?token=${token}`;
  // Establish WebSocket connection using the updated token
  const ws = new WebSocket(wsUrl);
});

Verification

To verify the fix, follow these steps:

  • Update the background.js and options.js files with the code changes
  • Reload the extension from chrome://extensions
  • Open the extension options page and enter a new gateway token
  • Save the settings
  • Click the extension icon on any tab to attach
  • Observe the background service worker console for the updated token in the WebSocket connection URL

Extra Tips

  • Ensure that the chrome.storage API is used correctly to store and retrieve the token
  • Verify that the token is updated correctly in the options.js file
  • Test the fix with different tokens to ensure the issue is fully resolved

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…

FAQ

Expected behavior

The extension should use the token saved in options for the WebSocket connection to the relay.

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 [Bug]: Chrome extension uses stale token for WebSocket relay connection despite correct token saved in options [3 comments, 2 participants]