node.js STUN stun.l.google.com:19302 用于什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20067739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:18:20  来源:igfitidea点击:

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

node.jswebrtcstun

提问by Vicky

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

我正在查看webrtc.htmlpeerconnection_server演示,它在两个 Chrome 浏览器之间运行良好。我的问题是, 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...

它是 Google 出于演示目的提供的第三方 STUN 服务器吗?如果在我的 JavaScript 代码中替换"stun.l.google.com:19302""toto",我仍然可以进行视频通话。但是因为我在同一个子网上,这可以解释......

回答by Altanai

  • 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.

  • 两个客户端都使用 STUN 服务器来确定它们在全球 Internet 上可见的 IP 地址。如果两个对等点都在同一个 NAT 后面,则不需要 STUN 设置,因为它们无论如何都是可以相互访问的。当对等点位于不同的网络上时,STUN 有效地发挥作用。

  • 正如我们所知,webRTC 是点对点的,并且在 webrtc 中必须使用 ice 候选。ICE 功能可以是两种方式中的任何一种,STUN 和 TURN。

  • 谷歌和其他网站提供了许多可以使用的 stun 服务器。您还可以根据 rfc5766 设置自己的 STUn 服务器。

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

希望能够激发出眩晕的内容和方式。

回答by Munim

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.

如果两个客户端在 NAT 之后,则需要一个 stun 服务器才能使用 webrtc 进行通信。您将需要该 stun 服务器来确保 NAT 背后的人可以使用您网页上的 webrtc 功能。