Servers are required!

Even though WebRTC is a p2p technology, there's always a signaling server required which transmits the initial token generated by one client to another, so that they can connect.

Types of WebRTC Servers

Signaling

It is always required, since WebRTC isn't completely p2p. It needs a signaling server to relay an offer from one client to another for the first time, after that they can pick it up the entire connection on their own.

It's inexpensive and can be setup within a few lines of socket.io code.

NAT Traversal

A Nat Traversal server is typically required in production scenarios. Before IPv6 there wasn't as many available IP addresses, hence sysadmins setup NATs in their setups which translated regular requests to the non routable address space IPs in the internal network. Hence the address exposed to the web is different then the IP address the machine has.

In certain scenarios due to the firewall limitations, certain UDP ports will be blocked and the connection might not go through.

To solve this, WebRTC gives us the ICE (Interactive Connectivity Establishment) protocol. It is a protocol for allowing a client behind a NAT or a firewall device to talk to another one which may or may not have those devices.

There are two types of servers that handle ICE transactions:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/11df9627-611e-48b8-a13f-e542e09d5a67/Untitled.png

Media

Media servers are usually needed when we are in a multi party scenario, since the cost of transferring multiple streams becomes exponential very quickly.

To improve this, there are several approaches but none of them is perfect and depends on the needs of the application.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b6fd60cb-238d-4ebd-a15d-96486bb01300/Untitled.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/45f5652b-ff43-4e9f-864f-36b21f97966a/Untitled.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/34655935-69ca-4726-81a9-dbe7f8a93584/Untitled.png

Gateway

Gateway servers are for applications who allow users to not only connect with browsers but other devices such as telephones. A gateway server basically acts a middleman which translates the streams into the appropriate formats and transfers them through the different protocols.