Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I simplify WebRTC signalling for computers on the same private network?

Tags:

webrtc

WebRTC signalling is driving me crazy. My use-case is quite simple: a bidirectional audio intercom between a kiosk and to a control room webapp. Both computers are on the same network. Neither has internet access, all machines have known static IPs.

Everything I read wants me to use STUN/TURN/ICE servers. The acronyms for this is endless, contributing to my migraine but if this were a standard application, I'd just open a port, tell the other client about it (I can do this via the webapp if I need to) and have the other connect.

Can I do this with WebRTC? Without running a dozen signalling servers?

For the sake of examples, how would you connect a browser running on 192.168.0.101 to one running on 192.168.0.102?

like image 288
Oli Avatar asked Nov 05 '15 11:11

Oli


2 Answers

STUN/TURN is different from signaling. STUN/TURN in WebRTC are used to gather ICE candidates. Signaling is used to transmit between these two PCs the session description (offer and answer). You can use free STUN server (like stun.l.google.com or stun.services.mozilla.org). There are also free TURN servers, but not too many (these are resource expensive). One is numb.vigenie.ca.

Now there's no signaling server, because these are custom and can be done in many ways. Here's an article that I wrote. I ended up using Stomp now on client side and Spring on server side.

I guess you can tamper with SDP and inject the ICE candidates statically, but you'll still need to exchange SDP (and that's dinamycally generated each session) between these two PCs somehow. Even though, taking into account that the configuration will not change, I guess you can exchange it once (through the means of copy-paste :) ), stored it somewhere and use it every time.

like image 178
Adrian Ber Avatar answered Nov 10 '22 20:11

Adrian Ber


If your end-points have static IPs then you can ignore STUN, TURN and ICE, which are just power-tools to drill holes in firewalls. Most people aren't that lucky.

Due to how WebRTC is structured, end-points do need a way to exchange call setup information (SDP) like media ports and key information ahead of time. How you get that information from A to B and back to A, is entirely up to you ("signaling server" is just a fancy word for this), but most people use something like a web socket server, the tic-tac-toe of client-initiated communication.

I think the simplest way to make this work on a private network without an internet connection is to install a basic web socket server on one of the machines.

As an example I recommend the very simple https://github.com/emannion/webrtc-web-socket which worked on my private network without an internet connection.

Follow the instructions to install the web socket server on e.g. 192.168.1.101, then have both end-points connect to 192.168.0.101:1337 with Chrome or Firefox. Share camera on both ends in the basic demo web UI, and hit Connect and you should be good to go.

If you need to do this entirely without any server, then this answer to a related question at least highlights the information you'd need to send across (in a cut'n'paste demo).

like image 2
jib Avatar answered Nov 10 '22 20:11

jib