测试TURN服务器的简单方法 [英] Easy way to test TURN server

查看:2500
本文介绍了测试TURN服务器的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在看这个站点,该站点应该是测试TURN服务器的表(根据此答案)。

I'm looking at this site, which is supposed to be table to test a TURN server (according this this answer).

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

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

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

I put in my server info, but couldn't find anything to determine if the server is working. The ice candidates section looks the same even its there's no server chosen.

我的TURN服务器安装在Amazon EC2上。我遵循了coturn存储库中的安装说明:

My TURN server is installed on Amazon EC2. I followed the install instructions from the coturn repository here:

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

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

以下是我从此处

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)

它似乎正在工作,但是我怎么知道?我为自己的无知表示歉意,我已经阅读了很多文档,对此我一无所知。

It appears to be working, but how do I know? I apologize for my ignorance, I've been reading so many docs on this I can't keep track of it all.

编辑:好吧,正在发生什么:)

Well something is happening :)

每当使用上述站点时,我现在都在转弯服务器上收到这些消息:

I'm receiving these on my turn server now whenever use the site mentioned above:

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部分,现在正在接收看来是成功的响应。仍然不是很清楚这是什么意思,但这只是一个开始:)

EDIT 2: I removed the ubuntu portion, and am now receiving what appears to be successful responses. Still don't really know what it means, but it's a start :)

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


推荐答案

编辑: github.io中的一个不错的实现,从注释中获取另一个答案(在IceTransports值中选择继电器):

A nice implementation in github.io taken from comment to another answer( choose "relay" in IceTransports value):

测试TURN服务器

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

run the below code in your browser console( firefox or chrome), replace 127.0.0.1 with your aws's external IP, that should give you the answer:

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 :请确保两件事,将aws的外部ip传递为启动TURN服务器时的部分参数,请确保您使用的端口已打开以用于接收和发送AWS设置。

P.S: make sure of two things, you pass aws's external ip as part of parameters when starting TURN server, make sure the port you are using is open for receiving and sending in aws settings.

这篇关于测试TURN服务器的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆