webrtc-node-app
This repository contains a simple WebRTC app, created for educational purposes.
A WebRTC video chat you can follow line by line
An educational Node app that walks through WebRTC by building a multi-room video chat with Express and SocketIO, from SDP offers to ICE candidates.
The idea behind WebRTC
This repository is a simple WebRTC app, created for educational purposes, with a README that teaches as it goes. WebRTC, short for Web Real Time Communication, is an open source project that enables peer-to-peer communication between browsers, letting two clients exchange video, audio, or data without a plugin or framework. The lesson starts with why that matters: direct browser-to-browser traffic avoids routing every message through a server, which the README says improves performance and cuts latency. WebSockets, by contrast, still need a server to pass messages along.
How the connection gets made
WebRTC needs a server only for signalling, the process that establishes and controls the connection. The protocol is not specified, so implementations choose their own, from WebSockets to SIP, XHR, or XMPP. The flow is concrete: the caller creates an offer with the Session Description Protocol and sends it, the callee answers with its own SDP, and once both sides set their local and remote session descriptions they know each other's codecs and media capabilities. But that is not enough to connect. Interactive Connectivity Establishment, ICE, gathers network candidates and uses STUN, and if needed TURN, to get past NATs and firewalls. STUN usually does the job, with expensive TURN relays reserved for restrictive corporate networks.
The three APIs
Three APIs carry the whole feature set. MediaStream, via getUserMedia, represents a device's media stream, audio and video tracks included, like a phone camera. RTCPeerConnection manages the actual connection, holding the SDP offers and answers and the ICE candidates. RTCDataChannel moves arbitrary data in real time, often compared to WebSockets but connecting browsers directly, which opens up things like gaming and encrypted file sharing. Media is encrypted with SRTP and data with DTLS.
The sample app
The example builds a multi-room video chat. The server uses Express with SocketIO for the real-time signalling, running on port 3000. Client views split between a room selection section and the video conference itself. Client-side code calls getUserMedia, and when a second client joins the same room, peer-to-peer media exchange begins while the server only handles signalling. Testing notes suggest ngrok for two devices and a reminder that HTTPS is required for getUserMedia. The README closes on the team's own use of WebRTC, adding a video chat to a client web app at Acid Tango where users could call web admins for free.
Community notes