Renegotiation and Connection State
Learn how WebRTC peer connections change over time: monitoring connection state, handling ICE restarts, and renegotiating SDP when media or network conditions change.
Connections Are Not Static
You have set up signaling, SDP, and ICE to create a connection. But a real session evolves: a user adds screen share, switches networks, or recovers from a drop. Handling these changes is called renegotiation and state management.
The Connection State Machine
An RTCPeerConnection reports its health through connectionState, moving through values like new, connecting, connected, disconnected, failed, and closed.
pc.onconnectionstatechange = () => {
console.log('state:', pc.connectionState);
};All lessons in this course
- The Role of Signaling Servers
- SDP: Session Description Protocol
- ICE Candidates and Connectivity
- Renegotiation and Connection State