From 5389a5cf9b9e1ccd8177b77f6f5dcfd1f43d70ca Mon Sep 17 00:00:00 2001 From: null Date: Fri, 22 May 2026 04:12:38 -0500 Subject: [PATCH] feat(gateway): add URL normalization for websocket schemes in gateway configuration --- backend/app/services/openclaw/gateway_rpc.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/app/services/openclaw/gateway_rpc.py b/backend/app/services/openclaw/gateway_rpc.py index 32abf1c..cadcd76 100644 --- a/backend/app/services/openclaw/gateway_rpc.py +++ b/backend/app/services/openclaw/gateway_rpc.py @@ -180,11 +180,22 @@ class GatewayConfig: disable_device_pairing: bool = False +def _normalise_gateway_scheme(url: str) -> str: + """Convert http/https gateway URLs to the ws/wss scheme websockets expects.""" + parsed = urlparse(url) + if parsed.scheme == "http": + return urlunparse(parsed._replace(scheme="ws")) + if parsed.scheme == "https": + return urlunparse(parsed._replace(scheme="wss")) + return url + + def _build_gateway_url(config: GatewayConfig) -> str: base_url: str = (config.url or "").strip() if not base_url: message = "Gateway URL is not configured." raise OpenClawGatewayError(message) + base_url = _normalise_gateway_scheme(base_url) token = config.token if not token: return base_url