Is WebRTC really peer-to-peer protocol?

アレックス picture アレックス · Apr 2, 2015 · Viewed 8.8k times · Source

WebRTC is a peer-peer communication protocol. I wonder, is it really peer-peer if it does require a web server? For example, to create a "room" one has to create it at apprtc.appspot.com or https://hello.firefox.com/something.

Answer

deceze picture deceze · Apr 3, 2015

It is a true P2P protocol in that it can establish direct server-less communication between two arbitrary parties on the internet. Once the communication is established, no 3rd party is needed.

This comes with a few caveats though:

  1. The two peers first need to find one another. This signalling step is purposefully omitted from the WebRTC specification, since the WebRTC protocol is not specific to browsers and can be used by any number of different devices in different circumstances. Each group of peers will have their own context and will require different discovery methods. You will probably also want a middleman which controls the flow of information according to some business rule.

    You could use some other P2P protocol to establish this initial signalling phase; for instance you could just broadcast UDP packets on your local subnet if the other peer is on the same subnet. You could also use carrier pigeons for your signalling; though this is likely impractical. The most practical way for this over the general internet within a browser is to use a central message broker of some kind or another.

  2. It is not always possible to establish direct connections between two arbitrary peers. Sometimes this is hindered by network topology realities, e.g. non-permissive firewalls or NAT routers. In this case it is physically impossible for the two peers to communicate in a P2P manner and a third party relay is required; this is included in the WebRTC specification in the form of a TURN server.

So, WebRTC is a full P2P protocol at heart, but it needs to work with simple networking realities which sometimes, or maybe often, requires a server's helping hand.