【问题标题】:Easy way to test TURN server测试 TURN 服务器的简单方法
【发布时间】:2015-12-01 21:09:14
【问题描述】:

我正在查看这个站点,它应该是用于测试 TURN 服务器的表 (according this this answer)。

plugin.temasys.com.sg/demo/samples/web/content/peerconnection/trickle-ice/index.html

我输入了我的服务器信息,但找不到任何东西来确定服务器是否正常工作。即使没有选择服务器,ice 候选部分看起来也一样。

我的 TURN 服务器安装在 Amazon EC2 上。我在这里按照 coturn 存储库中的安装说明进行操作:

github.com/coturn/coturn/blob/master/INSTALL

以下是我从here 执行启动 TURN 服务器的命令时在服务器中得到的:

RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Coturn-4.2.1.2 'Monza'
0:
Max number of open files/sockets allowed for this process: 4096
0:
Due to the open files/sockets limitation,
max supported number of TURN Sessions possible is: 2000 (approximately)
0:

==== Show him the instruments, Practical Frost: ====

0: TLS supported
0: DTLS supported
0: AEAD supported
0: Redis supported
0: PostgreSQL supported
0: MySQL supported
0: MongoDB is not supported
0: OpenSSL compile-time version 0x1000106f: fresh enough
0: Default Net Engine version: 3 (UDP thread per CPU core)

=====================================================

0: Config file found: /usr/local/etc/turnserver.conf
0: Listener address to use: 172.31.43.176
0: Relay address to use: 172.31.43.176
0: Config file found: /usr/local/etc/turnserver.conf
0: Domain name:
0: Default realm: realm
0: Config file found: /usr/local/etc/turnuserdb.conf
0: WARNING: cannot find certificate file: turn_server_cert.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because certificate file is not set properly
0: WARNING: cannot find private key file: turn_server_pkey.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because private key file is not set properly
0: pid file created: /var/run/turnserver.pid
0: IO method (main listener thread): epoll (with changelist)
0: WARNING: I cannot support STUN CHANGE_REQUEST functionality because only one IP address is provided
0: Wait for relay ports initialization...
0:   relay 172.31.43.176 initialization...
0:   relay 172.31.43.176 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: IPv4. UDP listener opened on: 172.31.43.176:3478
0: Total UDP servers: 0
0: Total General servers: 1
0: turn server id=0 created
0: IPv4. TCP listener opened on : 172.31.43.176:3478
0: IO method (cli thread): epoll (with changelist)
0: IPv4. CLI listener opened on : 127.0.0.1:5766
0: IO method (auth thread): epoll (with changelist)

它似乎正在工作,但我怎么知道?我为我的无知道歉,我已经阅读了很多关于这方面的文档,我无法全部跟踪。

编辑:嗯,事情正在发生:)

现在每当使用上述网站时,我都会在我的回合服务器上收到这些:

64: ERROR: check_stun_auth: Cannot find credentials of user <ubuntu>
64: session 000000000000000004: realm <realm> user <ubuntu>: incoming packet message processed, error 401: Unauthorised

编辑 2:我删除了 ubuntu 部分,现在收到似乎是成功的响应。仍然不知道这意味着什么,但这是一个开始:)

274: handle_udp_packet: New UDP endpoint: local addr 172.31.43.176:3478, remote addr 12.123.123.123:64064
274: session 000000000000000007: realm <realm> user <>: incoming packet BINDING processed, success
274: handle_udp_packet: New UDP endpoint: local addr 172.31.43.176:3478, remote addr 12.123.123.123:64068
274: session 000000000000000008: realm <realm> user <>: incoming packet BINDING processed, success
274: session 000000000000000007: realm <realm> user <>: incoming packet message processed, error 401: Unauthorised
274: session 000000000000000008: realm <realm> user <>: incoming packet message processed, error 401: Unauthorised
274: IPv4. Local relay addr: 172.31.43.176:56767
274: session 000000000000000007: new, realm=<realm>, username=<turnadm>, lifetime=600
274: session 000000000000000007: realm <realm> user <turnadm>: incoming packet ALLOCATE processed, success
274: IPv4. Local relay addr: 172.31.43.176:54363
274: session 000000000000000008: new, realm=<realm>, username=<turnadm>, lifetime=600
274: session 000000000000000008: realm <realm> user <turnadm>: incoming packet ALLOCATE processed, success
274: session 000000000000000007: realm <realm> user <turnadm>: incoming packet ALLOCATE processed, success
274: session 000000000000000008: realm <realm> user <turnadm>: incoming packet ALLOCATE processed, success

【问题讨论】:

    标签: amazon-web-services amazon-ec2 webrtc turn


    【解决方案1】:

    如果您有使用 WebRTC 的测试应用。

    您可以在 Firefox 上强制开启。

    标签:about:config

    搜索:media.peerconnection.ice.relay_only

    设置为true

    目前 Firefox 只使用 TURN 中继。

    【讨论】:

    • 在 chrome 浏览器中有什么方法可以做同样的事情吗?
    【解决方案2】:

    编辑: github.io 中的一个不错的实现,取自对另一个答案的评论(在 IceTransports 值中选择“中继”):

    Test TURN Server


    在您的浏览器控制台(firefox 或 chrome)中运行以下代码,将 127.0.0.1 替换为您的 aws 的外部 IP,这应该会给您答案:

    function checkTURNServer(turnConfig, timeout){ 
    
      return new Promise(function(resolve, reject){
    
        setTimeout(function(){
            if(promiseResolved) return;
            resolve(false);
            promiseResolved = true;
        }, timeout || 5000);
    
        var promiseResolved = false
          , myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection   //compatibility for firefox and chrome
          , pc = new myPeerConnection({iceServers:[turnConfig]})
          , noop = function(){};
        pc.createDataChannel("");    //create a bogus data channel
        pc.createOffer(function(sdp){
          if(sdp.sdp.indexOf('typ relay') > -1){ // sometimes sdp contains the ice candidates...
            promiseResolved = true;
            resolve(true);
          }
          pc.setLocalDescription(sdp, noop, noop);
        }, noop);    // create offer and set local description
        pc.onicecandidate = function(ice){  //listen for candidate events
          if(promiseResolved || !ice || !ice.candidate || !ice.candidate.candidate || !(ice.candidate.candidate.indexOf('typ relay')>-1))  return;
          promiseResolved = true;
          resolve(true);
        };
      });   
    }
    
    checkTURNServer({
        url: 'turn:127.0.0.1',
        username: 'test',
        credential: 'test'
    }).then(function(bool){
        console.log('is my TURN server active? ', bool? 'yes':'no');
    }).catch(console.error.bind(console));
    

    PS:确保两件事,在启动 TURN 服务器时将 aws 的外部 ip 作为参数的一部分传递,确保您使用的端口在 aws 设置中为接收和发送打开。

    【讨论】:

    • 嗨,如果我在 webrtc.github.io 链接上测试 Turn Server 以查看 TURN 服务器是否正常工作,我应该看到什么样的消息?
    • 我用这段代码测试了我的 Coturn 服务器(我把它放到了我的 html 页面中并修改了 uri、用户名和密码)以及 webrtc.github.io。我的服务器配置在 github.io 页面上成功,但此代码始终返回“否”。我试图调试这个,但无法弄清楚为什么这段代码会失败。
    • @mding5692,请参阅下面成功测试的输出。 Time Component Type Foundation Protocol Address Port Priority 0.010 1 host 0 udp addr.local 59895 126 | 32512 | 255 0.025 1 host 4 tcp addr.local 9 125 | 32704 | 255 0.026 2 host 0 udp addr.local 59896 126 | 32512 | 254 0.027 2 host 4 tcp addr.local 9 125 | 32704 | 254 11.207 Done
    猜你喜欢
    • 2015-04-30
    • 2015-10-09
    • 1970-01-01
    • 2020-11-12
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-03
    相关资源
    最近更新 更多