我已进行如下设置:
TurnAddress = 172.31.40.178
AltStunAddress = 172.31.40.179
TurnPort = 3478
AltStunPort = 5349
第一和第二IP都被配置和可以ping通,这是ifconfig的输出:
eth0: flags=4163 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
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 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 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
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
和端口是开放的。
的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作为领域。
当我尝试连接到转动服务器失败。我使用下面的代码来测试连接,使用正确的用户名和密码,它总是打印“不”:
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));
我将超出感谢任何帮助,我开始失去我的弹珠。
非常感谢。