reTurn Server(resiprocate)没有响应,配置错误?

时间:2016-11-24 13:36:43

标签: configuration server return stun turn

我已根据这些说明在rhel7上安装了resiprocate reTurn服务器,完全符合第2条: https://www.webrtc-experiment.com/docs/TURN-server-installation-guide.html

我已设置以下内容:

TurnAddress = 172.31.40.178
AltStunAddress = 172.31.40.179
TurnPort = 3478
AltStunPort = 5349

第一个和第二个IP都已配置并可以ping通,这是ifconfig的输出:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.40.178  netmask 255.255.240.0  broadcast 172.31.47.255
        inet6 fe80::45e:20ff:fe6b:6869  prefixlen 64  scopeid 0x20<link>
        ether 06:5e:20:6b:68:69  txqueuelen 1000  (Ethernet)
        RX packets 5100789  bytes 890198603 (848.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4742159  bytes 3984379336 (3.7 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.40.179  netmask 255.255.240.0  broadcast 172.31.47.255
        ether 06:5e:20:6b:68:69  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 460812  bytes 163626411 (156.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 460812  bytes 163626411 (156.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

并且端口已打开。

reTurn的netstat输出为:

tcp        0      0 172.31.40.178:3478      0.0.0.0:*
LISTEN      17177/reTurnServer
tcp        0      0 172.31.40.178:5349      0.0.0.0:*
LISTEN      17177/reTurnServer
tcp6       0      0 :::3478                 :::*
LISTEN      17177/reTurnServer
tcp6       0      0 :::5349                 :::*
LISTEN      17177/reTurnServer
udp        0      0 172.31.40.179:3478      0.0.0.0:*
         17177/reTurnServer
udp        0      0 172.31.40.178:3478      0.0.0.0:*
         17177/reTurnServer
udp        0      0 172.31.40.179:3479      0.0.0.0:*
         17177/reTurnServer
udp        0      0 172.31.40.178:3479      0.0.0.0:*
         17177/reTurnServer
udp6       0      0 :::3478                 :::*
         17177/reTurnServer

我已经设置了哈希密码,并使用了我的域名,例如。 test.example.com作为领域。

当我尝试连接转弯服务器时,它失败了。我使用以下代码测试连接,使用正确的用户名和密码,它始终打印&#34; no&#34;:

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:test.*****.com:3478',
            'credential': 'password',
            'username': 'username'
}).then(function(bool){
    console.log('is TURN server active? ', bool? 'yes':'no');
}).catch(console.error.bind(console));

对于任何帮助,我都会感激不尽,我开始失去我的弹珠。

非常感谢。

1 个答案:

答案 0 :(得分:1)

172.31.40.178属于私有IP地址范围。这意味着你从NAT后面运行STUN和TURN。如果您已将端口3478,3479和5349(UDP和TCP)正确地转发到您的服务器,那么这没有错。

您在问题中留下了足够的提示,建议您的服务器在Amazon EC2上运行。如果是这种情况,则端口转发由EC2实例的security group配置。对于与此实例关联的安全组,为UDP和TCP启用一组入站规则,允许端口3478,3479和5349用于IP范围0.0.0.0/0。另外,请检查您的VPC安全组和netweork acl设置,但默认情况下这些设置通常是全开启的。

否则,如果您不在亚马逊上,则应启用您的托管服务提供商或本地NAT,以将这些端口移植到服务器的IP。

另外,请仔细检查以确保您的IPTable规则(如果已启用)不会阻止流量。