The 1:1 connection lab
Take one peer connection apart: capture media, negotiate signaling, watch ICE choose a path, inspect getStats, send data, then break the path on purpose. Automatic rooms, manual SDP, and a solo loopback all share the same wire.
Lesson 03 — How WebRTC connectsMedia stage
NO LOCAL TRACKStart the camera or use the synthetic test feed. Local media never leaves the browser until a peer connection carries it.
Join a room or complete a manual exchange. Remote media appears only after the peer connection is connected.
Capture controls
Permission is requested only when you press a button.
Connect two peers
NO PEER CONNECTION2–40 letters, numbers, _ or -. No account, no display name, no personal information.
You
not joined
Room
—
Other peers
waiting
The newcomer offers to the existing peer. When signaling drops, an established media path should survive — signaling is only how the two sides find each other.
Signaling messages appear here once you join a room or exchange a manual offer.
Data channel
SCTP over DTLS · ordered chat and chunked file transfer
The chat unlocks when the data channel opens after DTLS.
5 MB LAB LIMIT · 8 KB CHUNKS · BACKPRESSURE AWARE · NO SERVER STORAGE
Break it
Filters apply to outbound candidates on the next negotiation.
Host, srflx, and relay candidates are all usable. The selected pair may be direct or relayed.
Connection should stay stuck in checking.
Killing signaling does not close an established media path. Reset the peer connection to force a new gather.
Completion
Record the 1:1 lab
Complete at least one connected peer path and open the data channel, then record the lab. You can keep experimenting afterward.
Lab: do and don't
PRODUCTION HABITSDo
Wait for ICE before judging a connection
new → checking → connected takes time and candidates. State 'checking' is not a verdict; getStats and the ICE log tell you what is actually happening.
Keep signaling and media separate
The data channel and RTP do not travel through your WebSocket. Killing signaling should not kill an established call; if it does, the app is coupling the two.
Stop tracks and close PCs
Camera LEDs stay on when tracks are alive. Close the peer connection, stop every track, and clear timers when the user leaves.
Don't
Don't trust a single STUN server
STUN only discovers an address; it does not relay. Networks that block UDP or use symmetric NAT need TURN, and TURN must use short-lived credentials.
Don't send files blindly
Watch bufferedAmount and pace chunks. A fast producer can grow the SCTP send buffer until memory and latency suffer; the lab waits for the low-water mark.
Don't hide permission failures
NotAllowedError, NotFoundError, and NotReadableError are different problems. Name the cause, then offer the synthetic feed instead of a generic failure.