【发布时间】:2019-06-16 13:55:07
【问题描述】:
我有一个 WebRTC 多方应用程序,它可以在 localhost 和 ngrok.io localhost 隧道上运行。但是,当我尝试与通过路由器连接的朋友进行测试时,我能够看到提议/答案交换以及 ICE 候选交换,但没有声音流过。
在第一次遇到这个问题后,我做了一些研究,了解到您需要一个 TURN 服务器才能通过路由器的 NAT。我正在使用我已确认在 https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ 中工作的公共 TURN 服务器
var configuration = {
"iceServers": [{ "url": "stun:stun2.1.google.com:19302" }],
url: 'turn:192.158.29.39:3478?transport=udp',
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
username: '28224511:1379330808'
};
yourConn = new webkitRTCPeerConnection(configuration);
yourConn2 = new webkitRTCPeerConnection(configuration);
yourConn3 = new webkitRTCPeerConnection(configuration);
声音数据包应该通过这个 TURN 服务器和我朋友的 NAT 路由,但我们仍然无法相互传输。
【问题讨论】:
-
您的 TURN 服务器应该列在
iceServers中。另见:developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/… -
@Brad 说了什么。此外,public TURN servers are a myth.
-
使用公共 TURN 凭据,trickle-ice 页面为我提供了主机和服务器自反候选,但没有中继候选。所以凭据不起作用。
标签: javascript webrtc audio-streaming nat turn