From 2a9bb36ee09d2905cb52198ca17bdd2048951e2a Mon Sep 17 00:00:00 2001 From: Nikita Davydov Date: Tue, 4 Aug 2026 10:34:36 +0300 Subject: [PATCH] Apply ICE preference when switching to TCP on unstable UDP (#4703) onMediaLossUpdate notified the participant handler directly, which only sends a leave request with resume action. handleConnectionFailed that actually switches the ICE preference to TCP/TLS was never called on this path, so the client reconnected over UDP again and the fallback kept firing every 30-60s without ever migrating. Fixes livekit/livekit#4702 --- pkg/rtc/transportmanager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/rtc/transportmanager.go b/pkg/rtc/transportmanager.go index 8257c1023..151af1bf1 100644 --- a/pkg/rtc/transportmanager.go +++ b/pkg/rtc/transportmanager.go @@ -976,6 +976,11 @@ func (t *TransportManager) onMediaLossUpdate(loss uint8) { t.lock.Unlock() t.params.Logger.Infow("udp connection unstable, switch to tcp", "signalingRTT", t.signalingRTT) + // switch ICE preference to TCP before asking the client to resume, + // the raw params handler only sends a leave request and does not + // reconfigure the transport, so the client would reconnect over UDP + // again and this path would keep firing + t.handleConnectionFailed(true) if t.params.UseSinglePeerConnection { t.params.PublisherHandler.OnFailed(true, t.publisher.GetICEConnectionInfo()) } else {