From 162896c93cf2ddd33eebfafa5c353976a6596576 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Fri, 1 Aug 2025 13:21:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(backend)=20allow=20enforcing=20WSS?= =?UTF-8?q?=20protocol=20to=20resolve=20browser=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The LiveKit API URL is necessary to interact with the API. It uses https protocol. Eplicit wss protocol is necessary in Websocket constructor for some older browsers. This resolves critical compatibility issues with legacy browsers (notably Firefox <124, Chrome <125, Edge <125) that lack support for HTTPS URLs in the WebSocket() constructor. Without explicit WSS URLs, WebSocket signaling connections may fail, crash, or be blocked entirely in these environments. The setting is optional and defaults to the current behavior when not specified, ensuring zero breaking changes for existing deployments. --- docs/installation.md | 1 + src/backend/core/api/__init__.py | 1 + src/backend/meet/settings.py | 3 +++ src/frontend/src/api/useConfig.ts | 1 + .../src/features/rooms/components/Conference.tsx | 16 +++++++++++++++- .../env.d/dev-keycloak/values.meet.yaml.gotmpl | 1 + 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index 03c0b8a7..d1fc87e0 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -336,6 +336,7 @@ These are the environmental options available on meet backend. | LIVEKIT_API_SECRET | LiveKit API secret | | | LIVEKIT_API_URL | LiveKit API URL | | | LIVEKIT_VERIFY_SSL | Verify SSL for LiveKit connections | true | +| LIVEKIT_FORCE_WSS_PROTOCOL | Enables WSS protocol conversion for legacy browser compatibility (Firefox <124, Chrome <125, Edge <125) where HTTPS URLs fail in WebSocket() constructor. | false | | RESOURCE_DEFAULT_ACCESS_LEVEL | Default resource access level for rooms | public | | ALLOW_UNREGISTERED_ROOMS | Allow usage of unregistered rooms | true | | RECORDING_ENABLE | Record meeting option | false | diff --git a/src/backend/core/api/__init__.py b/src/backend/core/api/__init__.py index beb0ec3b..5e400ca0 100644 --- a/src/backend/core/api/__init__.py +++ b/src/backend/core/api/__init__.py @@ -52,6 +52,7 @@ def get_frontend_configuration(request): }, "livekit": { "url": settings.LIVEKIT_CONFIGURATION["url"], + "force_wss_protocol": settings.LIVEKIT_FORCE_WSS_PROTOCOL, "enable_firefox_proxy_workaround": settings.LIVEKIT_ENABLE_FIREFOX_PROXY_WORKAROUND, }, } diff --git a/src/backend/meet/settings.py b/src/backend/meet/settings.py index f3ad1648..a7f4af11 100755 --- a/src/backend/meet/settings.py +++ b/src/backend/meet/settings.py @@ -492,6 +492,9 @@ class Base(Configuration): ), "url": values.Value(environ_name="LIVEKIT_API_URL", environ_prefix=None), } + LIVEKIT_FORCE_WSS_PROTOCOL = values.BooleanValue( + False, environ_name="LIVEKIT_FORCE_WSS_PROTOCOL", environ_prefix=None + ) LIVEKIT_ENABLE_FIREFOX_PROXY_WORKAROUND = values.BooleanValue( environ_name="LIVEKIT_ENABLE_FIREFOX_PROXY_WORKAROUND", environ_prefix=None, diff --git a/src/frontend/src/api/useConfig.ts b/src/frontend/src/api/useConfig.ts index 887c6223..3dc4feb5 100644 --- a/src/frontend/src/api/useConfig.ts +++ b/src/frontend/src/api/useConfig.ts @@ -39,6 +39,7 @@ export interface ApiConfig { manifest_link?: string livekit: { url: string + force_wss_protocol: boolean enable_firefox_proxy_workaround: boolean } } diff --git a/src/frontend/src/features/rooms/components/Conference.tsx b/src/frontend/src/features/rooms/components/Conference.tsx index 4e71df70..824f91eb 100644 --- a/src/frontend/src/features/rooms/components/Conference.tsx +++ b/src/frontend/src/features/rooms/components/Conference.tsx @@ -162,6 +162,20 @@ export const Conference = ({ kind: null, }) + /* + * Ensure stable WebSocket connection URL. This is critical for legacy browser compatibility + * (Firefox <124, Chrome <125, Edge <125) where HTTPS URLs in WebSocket() constructor + * may fail - the force_wss_protocol flag allows explicit WSS protocol conversion + */ + const serverUrl = useMemo(() => { + const livekit_url = apiConfig?.livekit.url + if (!livekit_url) return + if (apiConfig?.livekit.force_wss_protocol) { + return livekit_url.replace('https://', 'wss://') + } + return livekit_url + }, [apiConfig?.livekit]) + const { t } = useTranslation('rooms') if (isCreateError) { // this error screen should be replaced by a proper waiting room for anonymous user. @@ -185,7 +199,7 @@ export const Conference = ({