Javascript ICE失败,您的TURN服务器似乎已损坏,有关详细信息,请参阅关于:webrtc

Javascript ICE失败,您的TURN服务器似乎已损坏,有关详细信息,请参阅关于:webrtc,javascript,html,http,firefox,webrtc,Javascript,Html,Http,Firefox,Webrtc,我试图使用WebRTC查找客户端Ip地址,但在firefox中,我收到以下错误: ICE失败,您的回合服务器似乎已损坏,有关详细信息,请参阅关于:webrtc var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; var pc = new myPeerConnection({ iceServ

我试图使用WebRTC查找客户端Ip地址,但在firefox中,我收到以下错误:

ICE失败,您的回合服务器似乎已损坏,有关详细信息,请参阅关于:webrtc

     var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
            var pc = new myPeerConnection({ iceServers: [
   { url: "turn:numb.viagenie.ca:3478", username: "my@gmail.com", "credential": "xxxxxx" },
   { urls: "stun:stun.l.google.com:19302" }


] }),
                noop = function () { },
                localIPs = {},
                ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
                key;
            function ipIterate(ip) {
                if (!localIPs[ip]) onNewIP(ip);
                localIPs[ip] = true;
            }
            pc.createDataChannel("");
            pc.createOffer(function (sdp) {
                sdp.sdp.split('\n').forEach(function (line) {
                    if (line.indexOf('candidate') < 0) return;
                    line.match(ipRegex).forEach(ipIterate);
                });
                pc.setLocalDescription(sdp, noop, noop);
            }, noop);
            pc.onicecandidate = function (ice) {
                if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
                ice.candidate.candidate.match(ipRegex).forEach(ipIterate);
            };
var myPeerConnection=window.rtpeerconnection | | window.mozrtpeerconnection | | window.webkirtpeerconnection;
var pc=新的myPeerConnection({iceServers:[
{url:“turn:numb.viagenie.ca:3478”,用户名:my@gmail.com,“凭证”:“xxxxxx”},
{URL:“stun:stun.l.google.com:19302”}
] }),
noop=函数(){},
localIPs={},
ipRegex=/([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
钥匙
函数ipIterate(ip){
如果(!localIPs[ip])onNewIP(ip);
localIPs[ip]=真;
}
pc.createDataChannel(“”);
pc.createOffer(功能(sdp){
sdp.sdp.split('\n').forEach(函数(行){
if(line.indexOf('candidate')<0)返回;
line.match(ipRegex).forEach(ipIterate);
});
pc.setLocalDescription(sdp、noop、noop);
},noop);
pc.onicecandidate=函数(ice){
如果(!ice | |!ice.candidate | |!ice.candidate.candidate | |!ice.candidate.candidate.match(ipRegex))返回;
ice.candidate.candidate.match(ipRegex.forEach)(ipIterate);
};
登录关于:webrtc:

冰继电器日志

0.009 rtp主机3350409123 udp e6e7f092-e632-4986-97b2-90b20c3b15cd.local 59923 126 | 30 | 255 0.062 rtp srflx 842163049 udp IP 59923 100 | 30 | 255 0.313 rtp中继453802058 udp IP 57652 2 | 30 | 255 0.313完成
0.315这可能是由一些“隐私”插件引起的(例如,ublock的设置“防止WebRTC泄漏本地IP地址”可能导致此问题)。因此,请确保
about:config
中的
media.peerconnection.ice.proxy\u的值未设置为
true

任何人?看来turn服务器不是免费的。。由于某些原因,firefox需要turn服务器?你能试着用它来检索你的ICE中继候选人吗?是的,我正在把日志添加到主要问题中。事情是。。当我打开页面时,我得到了这个错误。。但是,当我从上一页单击“返回”到此页时..回发是有效的确定,因此轮到你似乎有效,因为浏览器检索其中继候选。请注意,您的公共IP已存在,您可能希望将其从您的帖子中删除。只是一个细节,您可能应该在
url
属性(第一个
iceServers
值)添加一个“s”