Vicky
Vicky

Reputation: 1532

what is STUN stun.l.google.com:19302 used for

I'm looking at the webrtc.html and peerconnection_server demo, and it is working fine between two Chrome browsers. My question is, what exactly is the first param of webkitPeerConnection ?

pc = new webkitPeerConnection("STUN stun.l.google.com:19302", onSignalingMessage);

Is it a third party STUN server given by Google for demo purpose ? If, in my JavaScript code, I replace "stun.l.google.com:19302" by "toto", I'm still able to make video calls. But as I'm on the same subnet, this can be explainable...

Upvotes: 56

Views: 131579

Answers (3)

Broteen Das
Broteen Das

Reputation: 502

A STUN server basically tells you what your public IP is. (In a nutshell)

Explanation: When collecting ICE Candidates (or the ways to connect to a peer), the WebRTC code collects all possible ways of connecting to a peer. Connecting via the WAN is one of those ways (or candidates). So in order to know what public IP address is assigned to a device by its router (applicable for Full Cone NAT), STUN servers tell you just that.

I recommend reffering to this video for a lucidly beautiful explanation.

Upvotes: 6

Altanai
Altanai

Reputation: 1393

  • STUN servers are used by both clients to determine their IP address as visible by the global Internet.If both the peers are behind the same NAT , STUN settings are not needed since they are anyways reachable form each other . STUN effectively comes into play when the peers are on different networks.

  • As we know that webRTC is peer to peer and the ice candidates are mandatory in webrtc. ICE functionality can be in any of the two ways , STUN and TURN .

  • There are many stun servers provided by google and other sites which one could use . You can also setup your own STUn server according to rfc5766.

Hope that gives a zest of what and how of stun .

Upvotes: 81

Munim
Munim

Reputation: 6510

A stun server is needed for two clients to communicate using webrtc if they are behind NAT. You will need that stun server to make sure people behind NAT can use the webrtc functionality on your web page.

Upvotes: 7

Related Questions