Network Optimization
lib-jitsi-meet implements robust network handling including ICE connection management, network quality monitoring, and automatic recovery mechanisms.
ICE Failed Handling
The IceFailedHandling class manages recovery from ICE connection failures on the JVB media session.
Architecture
Source: modules/connectivity/IceFailedHandling.ts:16-27
Recovery Strategy
When ICE fails, lib-jitsi-meet:
- Pings XMPP server to verify internet connectivity (65s timeout)
- Waits 2 seconds for ICE to recover
- If still failed, sends session-terminate to Jicofo
- Jicofo re-invites the participant to recreate the session
Source: modules/connectivity/IceFailedHandling.ts:10-14
Implementation
Starting Recovery
Source: modules/connectivity/IceFailedHandling.ts:63-85
Taking Action on Failure
Source: modules/connectivity/IceFailedHandling.ts:35-57
Canceling Recovery
Source: modules/connectivity/IceFailedHandling.ts:91-94
65 Second XMPP TimeoutThe 65-second ping timeout is intentional. XMPP cannot recover after 65 seconds without server communication - the server will reject resume attempts with item-not-found error.Do not reduce this timeout or recovery may fail.Source: modules/connectivity/IceFailedHandling.ts:70-72
Network Info Module
The NetworkInfo module tracks online/offline internet status.
Architecture
Source: modules/connectivity/NetworkInfo.ts:9-31
Usage
Updating Network Status
Source: modules/connectivity/NetworkInfo.ts:40-46
Checking Online Status
Source: modules/connectivity/NetworkInfo.ts:55-57
Integration
Applications using lib-jitsi-meet should wire network status:
Source: modules/connectivity/NetworkInfo.ts:14-18
Default is OnlineBy default, lib-jitsi-meet assumes the network is online:Applications must wire the network status for lib-jitsi-meet to properly handle offline scenarios. Without this, operations will fail gracefully but without optimization.Source: modules/connectivity/NetworkInfo.ts:28-30, 48-56
Connection Quality
The ConnectionQuality module monitors connection quality based on RTCStats.
Module Structure
Source: modules/connectivity/ directory
Available Modules:
IceFailedHandling.ts - ICE failure recovery
NetworkInfo.ts - Online/offline tracking
ConnectionQuality.ts - Quality monitoring
TrackStreamingStatus.ts - Track streaming state
ICE Connection States
lib-jitsi-meet normalizes ICE connection states across browsers:
The P2P connection may report “completed” state, but this is normalized to “connected” for consistency.
Source: modules/RTC/TraceablePeerConnection.ts:1254-1262
ICE State Transitions
Key States:
- new: ICE agent gathering addresses
- checking: ICE agent checking pairs
- connected: ICE agent found working connection
- completed: ICE agent finished (normalized to connected)
- failed: ICE agent exhausted all candidates
- disconnected: ICE agent lost connection
- closed: ICE agent shut down
DTLS Transport
lib-jitsi-meet monitors the DTLS transport for the peer connection:
All streams are bundled on a single transport for efficiency.
Source: modules/RTC/TraceablePeerConnection.ts:834-853
ICE Configuration
lib-jitsi-meet supports separate ICE configurations for JVB and P2P:
Source: CLAUDE.md:94
Force TURN Relay
When enabled, the browser will only generate relay (TURN) candidates, ensuring all traffic goes through the TURN server.
Source: modules/RTC/TraceablePeerConnection.ts:223
Network Resilience Best Practices
1. Monitor ICE State
2. Wire Network Status
3. Handle Reconnection
4. Use Adaptive Bitrate
5. Monitor Statistics
RTCStats Integration
lib-jitsi-meet sends analytics events to rtcstats:
This tracks ICE restarts for monitoring and debugging.
Source: modules/connectivity/IceFailedHandling.ts:4-5, 49
Connectivity Modules
Other connectivity-related modules:
TrackStreamingStatus
Monitors whether tracks are actively streaming:
- Tracks interruptions
- Detects playback issues
- Manages buffer state
ConnectionQuality
Calculates connection quality score:
- Based on RTCStats metrics
- Packet loss, jitter, RTT
- Audio/video quality indicators
Source: modules/connectivity/ directory
Network Diagnostics
Enable Detailed Logging
Trace ICE Candidates
Monitor DTLS State
Reduce Signaling Overhead
- Use JSON message encoding for large conferences
- Batch source updates
- Minimize presence updates
Optimize ICE Gathering
Enable ICE Restart
Next Steps