【问题标题】:How to stream WebRTC audio through a NAT?如何通过 NAT 流式传输 WebRTC 音频?
【发布时间】: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 路由,但我们仍然无法相互传输。

【问题讨论】:

标签: javascript webrtc audio-streaming nat turn


【解决方案1】:

您的轮到服务器凭据取自 https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/,并已于 2013 年过期。如果您使用 https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/,它应该告诉您这不起作用——如果它给您中继候选人,我会相当惊讶。

运行您自己的服务器。

【讨论】:

  • 确认:对我来说,问题中的凭据在涓涓冰测试页面上不起作用。
【解决方案2】:

你应该改变配置:

var configuration = { 
  "iceServers": [
    { "url": "stun:stun2.1.google.com:19302" },
    {
      "url": "turn:192.158.29.39:3478?transport=udp", 
      "credential": "yourpassword", 
      "username": "yourusename" 
    }
  ], 

};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多