【问题标题】:ICE failed, your TURN server appears to be broken, see about:webrtc for more detailsICE 失败,您的 TURN 服务器似乎已损坏,有关详细信息,请参阅 about:webrtc
【发布时间】:2020-05-30 06:27:53
【问题描述】:

我正在尝试使用 WebRTC 查找客户端 IP 地址,但在 Firefox 中我收到此错误:

ICE 失败,您的 TURN 服务器似乎已损坏,有关详细信息,请参阅 about: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);
            };

登录about:webrtc:

ICE 中继日志

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

【问题讨论】:

  • 有人吗?似乎转弯服务器不是免费的.. 并且 Firefox 出于某种原因需要转弯服务器?
  • 您可以尝试使用this website 检索您的 ICE 接力候选人吗?
  • 是的,我将日志添加到主要问题中
  • 奇怪的是..当我打开页面时我得到这个错误..但是当我从上一页点击返回到这个..所以回发工作正常
  • 好的,你的 TURN 似乎工作了,因为浏览器检索了它的中继候选。请注意,您的公共 IP 存在,您可能希望将其从帖子中删除。只是一个细节,您应该在url 属性(第一个iceServers 值)处添加一个“s”

标签: javascript html http firefox webrtc


【解决方案1】:

这可能是由某些“隐私”插件引起的(例如,ublock 的“防止 WebRTC 泄露本地 IP 地址” 设置可能会导致此问题)。因此,请确保about:configmedia.peerconnection.ice.proxy_only 的值未设置为true

【讨论】:

    猜你喜欢
    • 2013-12-24
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 2016-10-02
    相关资源
    最近更新 更多