41

我正在查看webrtc.htmlpeerconnection_server演示,它在两个 Chrome 浏览器之间运行良好。我的问题是, webkitPeerConnection 的第一个参数到底是什么?

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

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

4

2 回答 2

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

于 2014-03-13T11:20:27.887 回答
4

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

于 2013-11-19T09:51:51.743 回答