Card 10/ 10

RecapDifficulty: Advanced1 min

Recap: Real-Time Protocols

Three ways to keep a connection open, each answering who may send and how it survives a drop.

Real-time protocols let data arrive when it exists rather than when the client asks.

  • WebSocket upgrades an HTTP request with a 101 into a two-way channel of frames; the application reconnects after a drop.
  • Server-sent events keep a GET response open and write text events into it; the browser reconnects and resumes with Last-Event-ID.
  • WebRTC swaps an offer and answer through signalling, then sends encrypted media and data directly over UDP.
  • ICE gathers host, STUN and TURN candidates and tests pairs; TURN relays when no direct path works.
  • Idle timeouts close quiet connections; a heartbeat shorter than the shortest timeout keeps them open.
The four questions against the three protocols
QuestionWebSocketServer-sent eventsWebRTC
How it startsUpgrade and 101A long GETOffer, answer and ICE
Who may sendBothServerBoth peers
One messageA frame on TCPText linesEncrypted UDP packets
After a dropApplication reconnectsBrowser resumesICE restart