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