Repository navigation
feat(livekit): add retryThroughRelay flag - #24932
prlanzarin wants to merge 1 commit into
Conversation
WalkthroughAdds a new optional boolean LiveKit setting Sequence DiagramsequenceDiagram
participant App as Application Settings
participant Container as BBBLiveKitRoomContainer
participant Room as BBBLiveKitRoom
participant LiveKit as LiveKit API
participant Error as Error Handler
App->>Container: Load retryThroughRelay config
Container->>Room: Pass retryThroughRelay prop
Room->>LiveKit: Initial connect (default ICE policy)
LiveKit-->>Room: ConnectionError / failure
Room->>Error: onError invoked (logs includes hasEverConnected, forceRelay)
Note over Room: Evaluate:<br/>retryThroughRelay && !hasEverConnected && hasTurnServer && ConnectionError
alt Conditions met
Room->>Room: Set rtcConfig.iceTransportPolicy = 'relay' (force relay)
Room->>LiveKit: Reconnect with relay-only transport
LiveKit-->>Room: Success or failure
Room->>Room: Update hasEverConnectedRef / lastConnectUsedRelayRef
else Conditions not met
Room->>LiveKit: Standard reconnect flow
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bigbluebutton-html5/private/config/settings.yml (1)
959-961: Optional: expand the comment to capture full semantics.The comment accurately describes the retry behavior, but a couple of nuances from the PR description are worth documenting for operators: the flag is ignored when no TURN server is configured, does not apply after the first successful connect, and is not applied to client-initiated forced reconnections.
📝 Proposed doc refinement
- # retryThroughRelay: when the initial LiveKit connection fails, retries - # will force TURN/relay until the first successful connect. + # retryThroughRelay: when the initial LiveKit connection fails with a + # ConnectionError, retries force iceTransportPolicy='relay' (TURN) until + # the first successful connect. Has no effect after the room has + # connected at least once, is ignored if no TURN server is available, + # and does not apply to client-initiated forced reconnections. retryThroughRelay: false🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-html5/private/config/settings.yml` around lines 959 - 961, Update the inline comment for the retryThroughRelay setting in settings.yml to document the full semantics: state that retryThroughRelay applies only to initial LiveKit connection attempts and will force TURN/relay only until the first successful connect, it is ignored if no TURN server is configured, and it does not affect client-initiated forced reconnections; reference the retryThroughRelay setting name so operators can find and understand these caveats.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@bigbluebutton-html5/private/config/settings.yml`:
- Around line 959-961: Update the inline comment for the retryThroughRelay
setting in settings.yml to document the full semantics: state that
retryThroughRelay applies only to initial LiveKit connection attempts and will
force TURN/relay only until the first successful connect, it is ignored if no
TURN server is configured, and it does not affect client-initiated forced
reconnections; reference the retryThroughRelay setting name so operators can
find and understand these caveats.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7cd51b01-b861-4ea6-9037-10493d6e779b
📒 Files selected for processing (4)
bigbluebutton-html5/imports/ui/Types/meetingClientSettings.tsbigbluebutton-html5/imports/ui/components/livekit/component.tsxbigbluebutton-html5/imports/ui/core/initial-values/meetingClientSettings.tsbigbluebutton-html5/private/config/settings.yml
We're investigating connectivity failures where LK PCs are _not_ opting for relay even though ICE ends up failing on regular candidate pairs. With LK, we lack a counterpart of bbb-webrtc-sfu's retryThroughRelay flag that forces TURN on connection failures - which was designed precisely as stopgap for these scenarios. Add public.media.livekit.retryThroughRelay (default false). When the flag is on and the initial LK session fails with a ConnectionError, retries set iceTransportPolicy='relay' on the RTCConfiguration until the first successful connect. Once the room has connected at least once, the flag no longer applies: subsequent mid-session reconnections go through normal candidate selection, so long-lived sessions do not pay the relay overhead after recovering. The flag does not abide to forced reconnections (i.e. initiated by ourselves), nor is it honored if no TURN server is configured.
22f34fc to
cb9d5dc
Compare
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/livekit/component.tsx (1)
281-281: Optional:hasTurnServeris a "seen recently" signal, not a liveness signal.Per
useIceServers(bigbluebutton-html5/imports/ui/components/livekit/hooks.ts),hasSeenTurnServeris set fromturnServers.length > 0on the last successful fetch. If credentials have since expired or the TURN host is unreachable, forcingiceTransportPolicy: 'relay'will just fail faster — which is acceptable given theMAX_CONN_ATTEMPTScap, but worth keeping in mind when diagnosing logs. You may want to consider triggering arefetch()before the relay retry if the cached TTL has elapsed, so stale creds don't silently undermine the mitigation.No change required; flagging as a nit since this is a diagnostic/recovery path.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-html5/imports/ui/components/livekit/component.tsx` at line 281, The current relay-retry logic uses hasTurnServer (from useIceServers / hasSeenTurnServer) which is a "seen recently" signal and may be stale; update the retry path in the component that sets iceTransportPolicy: 'relay' to first call the hook's refetch() (useIceServers.refetch()) when the cached TTL has likely elapsed before forcing relay, so you refresh TURN credentials and avoid failing fast on expired/unreachable TURN; reference useIceServers, hasSeenTurnServer / hasTurnServer, refetch(), iceTransportPolicy: 'relay', and MAX_CONN_ATTEMPTS when implementing this check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@bigbluebutton-html5/imports/ui/components/livekit/component.tsx`:
- Line 281: The current relay-retry logic uses hasTurnServer (from useIceServers
/ hasSeenTurnServer) which is a "seen recently" signal and may be stale; update
the retry path in the component that sets iceTransportPolicy: 'relay' to first
call the hook's refetch() (useIceServers.refetch()) when the cached TTL has
likely elapsed before forcing relay, so you refresh TURN credentials and avoid
failing fast on expired/unreachable TURN; reference useIceServers,
hasSeenTurnServer / hasTurnServer, refetch(), iceTransportPolicy: 'relay', and
MAX_CONN_ATTEMPTS when implementing this check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5aa59624-7231-47fb-a131-df6d9d4e5efa
📒 Files selected for processing (4)
bigbluebutton-html5/imports/ui/Types/meetingClientSettings.tsbigbluebutton-html5/imports/ui/components/livekit/component.tsxbigbluebutton-html5/imports/ui/core/initial-values/meetingClientSettings.tsbigbluebutton-html5/private/config/settings.yml
🚧 Files skipped from review as they are similar to previous changes (2)
- bigbluebutton-html5/imports/ui/Types/meetingClientSettings.ts
- bigbluebutton-html5/private/config/settings.yml
✅ Automated tests have passed! |
|
This pull request has conflicts ☹ |



What does this PR do?
for relay even though ICE ends up failing on regular candidate pairs.
With LK, we lack a counterpart of bbb-webrtc-sfu's retryThroughRelay
flag that forces TURN on connection failures - which was designed
precisely as stopgap for these scenarios.
flag is on and the initial LK session fails with a ConnectionError,
retries set iceTransportPolicy='relay' on the RTCConfiguration until
the first successful connect.
subsequent mid-session reconnections go through normal candidate selection,
so long-lived sessions do not pay the relay overhead after recovering.
ourselves), nor is it honored if no TURN server is configured.
Closes Issue(s)
None
Motivation
Related #24615