Skip to content

Commit 3abcbd8

Browse files
ralyodioclaude
andcommitted
fix(sfu): viewer/subscriber must honor TURN relay + Force relay too
The host SFU connection passed rtcConfig (TURN iceServers + Force-relay iceTransportPolicy), but the viewer/subscriber connection called room.connect(url, token) with NO rtcConfig — so it ignored both the TURN servers and the Force-relay toggle, went direct (srflx), and DTLS-timed-out on restrictive NATs ("could not establish pc connection") even with Force relay ON. Pass buildSfuRtcConfig(data.iceServers) on the viewer connect, mirroring the host. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7c8af55 commit 3abcbd8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/desktop/src/renderer/hooks/useWebRTCViewerSFUAPI.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from 'livekit-client';
1717
import { API_BASE_URL } from '../../shared/config';
1818
import { getElectronAPI } from '@/lib/ipc';
19+
import { buildSfuRtcConfig } from '@/lib/iceConfig';
1920
import type {
2021
ConnectionState,
2122
QualityMetrics,
@@ -374,7 +375,7 @@ export function useWebRTCViewerSFUAPI({
374375
}
375376

376377
const { data } = (await tokenRes.json()) as {
377-
data: { token: string; url: string; roomName: string };
378+
data: { token: string; url: string; roomName: string; iceServers?: RTCIceServer[] };
378379
};
379380

380381
// Create and connect room
@@ -477,8 +478,13 @@ export function useWebRTCViewerSFUAPI({
477478
setDataChannelReady(false);
478479
});
479480

480-
// Connect to LiveKit
481-
await room.connect(data.url, data.token);
481+
// Connect to LiveKit. Pass the TURN iceServers + honor "Force relay"
482+
// (same as the host path) — without rtcConfig the subscriber went
483+
// direct and DTLS-timed-out on restrictive NATs ("could not establish
484+
// pc connection") even with Force relay enabled.
485+
await room.connect(data.url, data.token, {
486+
rtcConfig: buildSfuRtcConfig(data.iceServers),
487+
});
482488

483489
// Enable mic after connecting
484490
try {

0 commit comments

Comments
 (0)