WebRTC on the local network?

I read about WebRTC and it looks very promising. I wanted to make a simple game that automatically connects people on the same network. Although I could find people asking about something like this and answers telling them that it was possible, I could not find any clear guidelines on how to do this.

However, I am very new to WebRTC and web programming in general. So maybe I just don’t know what to look for.

So, how can I automatically connect people using WebRTC on a local network without having to start a separate server or connect to the Internet? They should be able to open the html file on their computer and connect to everyone who does this on the same network, even if there is no Internet.

Thanks!

+15
source share
3 answers

At least one machine must be a server, in the sense that it needs to open the port that it is listening on. It is a fact of life with all connections; when one machine opens the connection, there must be another machine on the other end that responds. Without this, it is impossible to establish a connection.

If you want one or all computers to listen on the port, you can configure WebRTC on the local network. In this case, you will not need STUN or TURN because there is no NAT traversal.

WebRTC does not require STUN or TURN on the local network. WebRTC endpoints can generate local ICE candidates using their known local network addresses. They exchange via signaling, either directly in the SDP, or as ICE candidates for the ICE trickle. A peer-to-peer connection can be established without the need for a connection to a STUN server external to the local network.

+9
source

Before two partners can establish a direct connection, both of them must exchange data with a data set (network parameters, multimedia configuration, protocols used, etc.) so that they can understand how to connect to each other. They can perform this process using SDP (Session Description Protocol).

Therefore, you need a signaling server on the network that is accessible to every potential partner. When a client wants to connect to the WebRTC network, it must first connect to the alarm server. Then, the signaling server will notify the other peers that we have a new one, and all peers will exchange data with the SDP through the signaling server. After that, peers will be able to establish a direct relationship with a new partner. When a direct connection is established, all data flows between peers directly.

+4
source

WebRTC cannot work without any signaling mechanism. Basically, your customers should know at least something about each other, and this β€œsomething” in WebRTC terms is an SDP (session description protocol) package. After exchanging SDP packets, WebRTC will try to connect clients in the most direct way.

Try this article: http://www.html5rocks.com/en/tutorials/webrtc/basics/

This will give you a general idea of ​​how WebRTC works, and you will answer your own question. Key words: alarm, STUN and TURN.

Good luck

+3
source

All Articles