最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ICE failed, your TURN server appears to be broken, see about:webrtc for more details - Stack Overflow

programmeradmin2浏览0评论

Im trying to find client Ip address using WebRTC, but in firefox im getting this error :

ICE failed, your TURN server appears to be broken, see about:webrtc for more details

     var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
            var pc = new myPeerConnection({ iceServers: [
   { url: "turn:numb.viagenie.ca:3478", username: "[email protected]", "credential": "xxxxxx" },
   { urls: "stun:stun.l.google: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);
            };

log in about:webrtc:

ICE Relay log

0.009 rtp host 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 relay 453802058 udp IP 57652 2 | 30 | 255 0.313 Done 0.315

Im trying to find client Ip address using WebRTC, but in firefox im getting this error :

ICE failed, your TURN server appears to be broken, see about:webrtc for more details

     var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
            var pc = new myPeerConnection({ iceServers: [
   { url: "turn:numb.viagenie.ca:3478", username: "[email protected]", "credential": "xxxxxx" },
   { urls: "stun:stun.l.google.: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);
            };

log in about:webrtc:

ICE Relay log

0.009 rtp host 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 relay 453802058 udp IP 57652 2 | 30 | 255 0.313 Done 0.315

Share Improve this question edited Feb 15, 2020 at 16:15 drma usama asked Feb 14, 2020 at 12:43 drma usamadrma usama 1051 gold badge2 silver badges10 bronze badges 7
  • anyone? it seems that turn servers are not free.. and firefox for some reason require turn server? – drma usama Commented Feb 14, 2020 at 13:52
  • Could you try to retrieve your ICE relay Candidate using this website? – Antonin M. Commented Feb 14, 2020 at 15:05
  • Yes, I am adding the log into main question – drma usama Commented Feb 14, 2020 at 15:06
  • wierd thing is.. when i open the page I get this error.. but when I click back from previous page to this..so postback is works fine – drma usama Commented Feb 14, 2020 at 15:09
  • Ok, so your TURN seems to work because the browser retrieves its relay candidate. Note that your public IP is present and you may want remove it from your post. Just a detail, you should maybe add an 's' at the url attribute (the first iceServers value) – Antonin M. Commented Feb 14, 2020 at 15:15
 |  Show 2 more ments

2 Answers 2

Reset to default 1

This could be caused by some "privacy" addons (for example, the "Prevent WebRTC from leaking local IP addresses" setting of ublock could cause this problem). So, make sure the value of media.peerconnection.ice.proxy_only in about:config is not set to true

go to about:webrtc in firefox and tap clear history and clear log. in my case that's work for me

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论