Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC on local network? [closed]

Tags:

webrtc

I've been reading about WebRTC and it looks very promising. I wanted to make a simple lan game that automatically connects people on the same network. Though I could find people asking about something similar, and answers telling them it was possible, I couldn't find any clear tutorials on how it can be done.

I am however very new to WebRTC and web programming in general. So maybe I just don't know what to search for.

So, how can I automatically connect people using WebRTC on a local network without anyone having to run a separate server or connect to the internet? They should be able to open a html file on their computer and connect to everyone else doing that on the same network, even when there's no internet.

Thanks!

like image 932
The Oddler Avatar asked Aug 23 '15 20:08

The Oddler


People also ask

Can WebRTC work without Internet?

There is no internet connection to the outside world in this scenario. One of the pcs would be able to enter the ip address of the other pc manually and connect to it using that hardcoded IP.

Why does WebRTC fail?

If the connection fails, it could be a problem of: Signaling: your browser (or iQunet Server) is not allowed to contact peer.iqunet.lu SSL port 80/443. WebRTC data traffic: your computer (or iQunet Server) are behind a very strict firewall that drops all UDP, STUN, TURN etc.

What is WebRTC issue?

WebRTC Software IssuesErrors associated with the signaling software used to negotiate connections e.g. SIP/XMPP, SDP generation, SDP negotiation errors.

How does WebRTC Server work?

How does WebRTC work? WebRTC uses JavaScript, APIs and Hypertext Markup Language to embed communications technologies within web browsers. It is designed to make audio, video and data communication between browsers user-friendly and easy to implement. WebRTC works with most major web browsers.


3 Answers

At least one machine needs to be a server, in the sense that it needs to have a port open that it listens on. This is a fact of life with all connections; when one machine opens a connection, there needs to be another machine on the other end that responds. Without this, no connections can ever be made.

If you are willing to have one or all machines listening on a port, then you can setup WebRTC on a LAN. In this case, you will not need STUN or TURN because there is no NAT traversal.

WebRTC does not need STUN or TURN on a LAN. WebRTC endpoints can generate local ICE candidates using their known addresses on the LAN. These get exchanged through signaling, either in directly in the SDP, or as ICE candidates in trickle ICE. The peer connection can be setup without ever needing to contact a STUN server external to the LAN.

like image 190
mattm Avatar answered Oct 14 '22 06:10

mattm


WebRTC cannot work without some sort of signaling mechanism. Basically, your clients need to know at least something about each other, and this 'something' in the terms of WebRTC is an SDP package (Session Description Protocol). After they exchange SDP packages, WebRTC engine will try to connect clients in the most direct way.

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

It will give you basic understanding of how WebRTC works, and you will answer your question yourself. Keywords: signaling, STUN and TURN.

Good luck!

like image 41
Alexey Ershov Avatar answered Oct 14 '22 07:10

Alexey Ershov


Before two peers could establish direct connection, they both should exchange with a set of data (network parameters, media configuration, usable protocols, etc.), so they would figure out how to connect to each other. They can do this process with using SDP (Session Description Protocol).

Hence, you need a signaling server in the network that would be reachable by every potential peer. When a client wants to connect to the 'WebRTC network', it should first connect to the signaling server. Then, signaling server will notify other peers that we have a new one, and all peers will exchange data with SDP via the signaling server. After that, peers would be able to establish direct connection to the new peer. When direct connection is established, all data goes between peers directly.

like image 42
fycth Avatar answered Oct 14 '22 08:10

fycth