WebRTC peers send audio and video to each other directly in most cases. To find each other and to get through network address translation (NAT) and firewalls, they need the help of up to three servers.
Signaling server
Two peers that want to connect know nothing about each other. A signaling server lets them join a named room, see who else is there and exchange the messages that set up a connection: the offer, the answer and the list of possible network addresses (ICE candidates). Audio and video do not pass through it.
The traffic and processor load of a signaling server are small, but no connection can start without it. Run your own server in production: see Signaling server deployment and usage.
STUN server
Inside one local network every peer can reach the others by its local address. Behind a router with NAT a peer does not know under which public address it is seen from outside. A STUN server answers that question, and the peers can then try to connect directly over the Internet.
A STUN server has little to do, so a public one can be used. The default value of the stun_server property is stun:stun.l.google.com:19302. A signaling server can announce its own STUN list, which then replaces this value.
TURN server
Some networks do not allow a direct connection at all: a firewall blocks UDP or the ports in use, or the NAT gives a different public port for every destination (symmetric NAT). A TURN server has a public address that both peers can reach, and it relays the audio and video between them.
All relayed media goes through the TURN server, so it needs network bandwidth for every connection it serves. Run it on a machine with a suitable network link. See TURN server deployment and usage.
Summary
| Server | Needed | Carries media | Provided by Medialooks |
|---|---|---|---|
| Signaling | Always | No | Yes, as source code and a Docker image |
| STUN | When peers are behind NAT | No | No; a public server is set by default |
| TURN | When a direct connection is impossible | Yes | Not included with the 1.0 signaling server |
Still have questions?
Tell us what didn’t work or what you’d like clarified.