我有一个webrtc应用程序,它工作正常,但出于测试目的,我需要测试我的TURN服务器是否工作,但因为两个测试设备都在同一个网络中,我无法测试,认为下面的代码会限制候选人只有那些使用TURN服务器,
function onIceCandidate(event, targetSessionID, targetUserName) {
if (event.candidate) {
var candidate = event.candidate.candidate;
if(candidate.indexOf("relay")<0){ // if no relay address is found, assuming it means no TURN server
return;
}
sendMessage(candidate); // using socket.io to send to the otherside
...
Run Code Online (Sandbox Code Playgroud)
但我注意到了(非常沮丧),这不起作用,因为当同伴创建答案描述时,
....
a=candidate:0 1 UDP 2128609535 13.198.98.221 58779 typ host
a=candidate:0 2 UDP 2128609534 13.198.98.221 58780 typ host
....
Run Code Online (Sandbox Code Playgroud)
这意味着,通信是直接的,而不是通过TURN服务器,我假设这是正确的吗?现在,如何强制webrtc使用TURN服务器?