【问题标题】:Implementing our own STUN/TURN server for WebRTC Application [duplicate]为 WebRTC 应用程序实现我们自己的 STUN/TURN 服务器 [重复]
【发布时间】:2014-04-09 15:35:06
【问题描述】:

我正在开发一个 webrtc 应用程序,并且必须实现以下 TURN 服务器。

https://code.google.com/p/rfc5766-turn-server/

我正在学习本教程。

http://www.dialogic.com/den/developer_forums/f/71/t/10238.aspx

它说在创建 RTCPeerConnection 的 javascript 代码中引用 TURN 服务器,如下所示。

var pc_config = {"iceServers": [{"url": "stun:stun.l.google.com:19302"},
  {"url":"turn:<turn_server_ip_address>", "username":"my_username", "credential":"my_password"}]};

pc_new = new webkitRTCPeerConnection(pc_config);

我有点困惑,为什么我们要引用 Google 的公共 STUN 服务器。我以为 RFC5766 TURN 服务器里面有 STUN。

RFC5766 是否只是 TURN 服务器?而不是 STUN 服务器?我们不能使用 Google 提供的 STUN 服务器来实现我们自己的 STUN 服务器吗?

对不起,这么幼稚的问题。我是 WebRTC 新手。

谢谢。

【问题讨论】:

    标签: webrtc stun rfc5766turnserver turn


    【解决方案1】:

    TURN是STUN的扩展,所以TURN服务器也有STUN功能。

    https://code.google.com/p/rfc5766-turn-server/ 也可用作 STUN,因此您可以尝试编写如下内容:

    var pc_config = {
        "iceServers": [{
            "url":"turn:my_username@<turn_server_ip_address>",
            "credential":"my_password"
        }]
    };
        
    pc_new = new webkitRTCPeerConnection(pc_config);
    

    【讨论】:

    • 构建我们自己的 TURN 和 STUN 服务器实现(不使用预构建服务器),您有什么建议?
    • @NikhilKinkar 我不建议这样做,因为它可能需要很长时间我建议使用 CoTurn 开源服务器,因为它是现在最流行的服务器
    • @Nikhil Kinkar 您是否设置了自己的 TURN 和 STUN 服务器?
    • 现在是 2022 年,你应该使用 github.com/coturn/coturn(这是更新后的后续项目)
    【解决方案2】:

    最近我正在捕获我的 Kurento WebRTC 服务器数据包,并意识到它一直在使用这个 www.stunprotocol.org 域进行 STUN 请求。一个名为stuntman的工具可以为你创建一个简单的STUN服务器。

    只需在 Linux 主机上执行以下操作:

    1. sudo apt-get update
    2. sudo apt-get install stuntman-server
    3. stunserver --mode full --primaryinterface 100.101.102.103
      (应将 100.101.102.103 替换为您的 IP 地址)
    4. 打开This Link 测试您的STUN 服务器。

    例如STUNTURN URI:

    stun:100.101.102.103:3478
    

    通过我提到的这个过程,我的机器上一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-01
      • 2021-08-10
      • 2014-06-11
      • 1970-01-01
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多