mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:47:39 +00:00
fix(browser): rewrite 0.0.0.0 and [::] wildcard addresses in CDP WebSocket URLs
Containerized browsers (e.g. browserless in Docker) report `ws://0.0.0.0:<internal-port>` in their `/json/version` response. `normalizeCdpWsUrl` rewrites loopback WS hosts to the external CDP host:port, but `0.0.0.0` and `[::]` were not treated as addresses needing rewriting, causing OpenClaw to try connecting to `ws://0.0.0.0:3000` literally — which always fails. Fixes #17752 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
4bfa800cc7
commit
dfa3605bee
@@ -320,6 +320,22 @@ describe("cdp", () => {
|
||||
expect(normalized).toBe("wss://user:pass@example.com/devtools/browser/ABC?token=abc");
|
||||
});
|
||||
|
||||
it("rewrites 0.0.0.0 wildcard bind address to remote CDP host", () => {
|
||||
const normalized = normalizeCdpWsUrl(
|
||||
"ws://0.0.0.0:3000/devtools/browser/ABC",
|
||||
"http://192.168.1.202:18850?token=secret",
|
||||
);
|
||||
expect(normalized).toBe("ws://192.168.1.202:18850/devtools/browser/ABC?token=secret");
|
||||
});
|
||||
|
||||
it("rewrites :: wildcard bind address to remote CDP host", () => {
|
||||
const normalized = normalizeCdpWsUrl(
|
||||
"ws://[::]:3000/devtools/browser/ABC",
|
||||
"http://192.168.1.202:18850",
|
||||
);
|
||||
expect(normalized).toBe("ws://192.168.1.202:18850/devtools/browser/ABC");
|
||||
});
|
||||
|
||||
it("upgrades ws to wss when CDP uses https", () => {
|
||||
const normalized = normalizeCdpWsUrl(
|
||||
"ws://production-sfo.browserless.io",
|
||||
|
||||
Reference in New Issue
Block a user