what happens when users briefly lose internet conn...
# ask-ai
s
what happens when users briefly lose internet connection and how to control it ?
t
Thanks for reaching out, Alex. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking what happens when users briefly lose internet and how you can control that behavior — here’s a concise guide. What happens when connection is briefly lost • The SDK detects interruptions and attempts an ICE restart to restore the WebRTC connection; this usually causes only a short media pause. • If ICE restart can't recover, the client performs a full reconnection: the SDK state moves through
Reconnecting
→
Reconnected
(or
Disconnected
), participants may briefly appear disconnected, and tracks are republished automatically. • Mobile network changes (Wi‑Fi ⇄ cellular) are handled via ICE restart as well. • If client/server state diverges, the server may disconnect with a
STATE_MISMATCH
reason; reconnection typically resolves this. How you can control and handle it • Listen for reconnection events and update UI:
Copy code
room.on('reconnecting', () => { /* show reconnecting UI */ });
room.on('reconnected',  () => { /* restore UI */ });
• Use Adaptive Stream so LiveKit reduces quality or pauses upstream video automatically when bandwidth drops. • Use selective subscription / manual track control: ◦ Disable
autoSubscribe
and subscribe only to required tracks. ◦ Use
publication.setEnabled(false)
to stop sending/receiving a track without a full negotiation, saving bandwidth. • Implement client-side monitoring to proactively lower quality or disable nonessential tracks during poor network conditions (e.g., change simulcast layer). • Ensure tokens are refreshed during sessions (short expiry) so reconnections don’t require re-authentication. Best practices • Design the UI to show reconnecting state and graceful degradation (lower frame rate/resolution). • Prefer adaptive streaming plus selective subscriptions to minimize disruption. • Test on mobile with Wi‑Fi/cellular switching and simulate short disconnects to verify behavior. Do you want code examples for adaptive stream setup, manual subscription flow, or a sample reconnection UI pattern? Sources: Connecting to LiveKit | LiveKit docs | client-sdk-android | livekit/livekit_composite | DeepWiki | client-sdk-swift | livekit/livekit_composite | DeepWiki | Understanding the STATE_MISMATCH Disconnect Reason | Subscribing to tracks | LiveKit docs