Skip to main content

WebRTC without Signaling Server

I was reading MDN’s article on signaling and video calling, and encountered this part:

WebRTC is a fully peer-to-peer technology for the real-time exchange of audio, video, and data, with one central caveat. A form of discovery and media format negotiation must take place, as discussed elsewhere, in order for two devices on different networks to locate one another. This process is called signaling and involves both devices connecting to a third, mutually agreed-upon server. Through this third server, the two devices can locate one another, and exchange negotiation messages.

It then goes on to talk about SDP, the protocol used to exchange signaling information, and guides you through implementing a video-calling app.

I started wondering, do you really need that third server? Is there anything preventing peers from exchanging the SDP offer and answer through some other means, like IRC or similar? It turns out there’s not!

Try the following:

  1. Press the Create button below to create an SDP offer.
  2. Copy the offer, and send it to someone. (Let’s call her Alice.)
  3. Have Alice go to this same URL, and paste the offer you sent her.
  4. An SDP answer will be generated. Have Alice send it back to you.
  5. Paste the answer, and an RTC connection between you two will be established.
  6. You can now see and message each other. Profit!

In my implementation, both offer and answer are compressed using lz-string, so that they’re easier to send around, but it’s not a requirement.


Signaling
Chat

Resources