Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何连接到我的stun服务器?_Javascript_Html_Webrtc_Stun_Simplehttpserver - Fatal编程技术网

Javascript 如何连接到我的stun服务器?

Javascript 如何连接到我的stun服务器?,javascript,html,webrtc,stun,simplehttpserver,Javascript,Html,Webrtc,Stun,Simplehttpserver,我必须通过开源构建一个stun服务器。 但我无法访问我的stun服务器。 这是我的密码 您的本地IP地址: 您的公共IP地址: 您的IPv6地址: //获取与帐户关联的IP地址 函数getIPs(回调){ var ip_dups={}; //firefox和chrome的兼容性 var RTCPeerConnection=window.RTCPeerConnection ||window.mozRTPeerConnection ||window.webkirtpeerconnecti

我必须通过开源构建一个stun服务器。

但我无法访问我的stun服务器。 这是我的密码


您的本地IP地址:
    您的公共IP地址:
      您的IPv6地址:
        //获取与帐户关联的IP地址 函数getIPs(回调){ var ip_dups={}; //firefox和chrome的兼容性 var RTCPeerConnection=window.RTCPeerConnection ||window.mozRTPeerConnection ||window.webkirtpeerconnection; var useWebKit=!!window.webkittrpeerconnection; //使用iframe绕过原始webrtc阻塞 如果(!RTPeerConnection){ //注意:在脚本标记正上方的页面中需要有一个iframe // // //…getIPs打电话来这里。。。 // var win=iframe.contentWindow; rtpeerconnection=win.rtpeerconnection ||win.MozRTPeerConnection ||win.webkirtpeerconnection; useWebKit=!!win.webkirtpeerconnection; } //数据连接的最低要求 变量mediaConstraints={ 可选:[{RtpDataChannels:true}] }; //我的stun服务器ip var服务器={iceServers:[{URL:“stun:39.xxx.xxx.xxx”}]; //构造新的RTPeerConnection var pc=新的RTPeerConnection(服务器、媒体约束); 函数handleCandidate(候选函数){ //只匹配IP地址 var ip_regex=/([0-9]{1,3}(\.[0-9]{1,3}){3}{124;[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/ var ip_addr=ip_regex.exec(候选者)[1]; //删除重复项 if(ip地址[ip地址]==未定义) 回调(ip地址); ip_dups[ip_addr]=真; } //倾听候选事件 pc.onicecandidate=函数(ice){ //跳过非候选事件 国际单项体育联合会(ice候选人) handleCandidate(ice.candidate.candidate); }; //创建虚假数据通道 pc.createDataChannel(“”); //创建报价sdp pc.createOffer(函数(结果){ //触发stun服务器请求 pc.setLocalDescription(结果,函数(){},函数(){}); },函数(){}); //等一会儿,让一切都完成 setTimeout(函数(){ //从本地描述中读取候选人信息 var lines=pc.localDescription.sdp.split('\n'); 行。forEach(函数(行){ if(line.indexOf('a=candidate:')==0) handleCandidate(行); }); }, 1000); } //在页面中插入IP地址 getIPs(功能(ip){ 控制台日志(ip); var li=document.createElement(“li”); li.textContent=ip; //本地IP 如果(ip匹配(/^(192\.168\.| 169\.254\.| 10\.| 172\.(1[6-9]| 2\d|3[01])/) document.getElementsByTagName(“ul”)[0].appendChild(li); //IPv6地址 else if(ip.match(/^[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}$/) document.getElementsByTagName(“ul”)[2]。appendChild(li); //假设其余的是公共IP 其他的 document.getElementsByTagName(“ul”)[1]。appendChild(li); });
        您所说的无法访问是什么意思?您是否在端口3478的服务器上尝试过简单的telnet?如果您使用的端口与您应该在配置中指定的端口不同。是的,我可以。我在端口3478的服务器上尝试了telnet。StuntMan TCP Stun服务器的工作您确实通过“Stun:39.xxx.xxx.xxx”字段编辑了您的Stun服务器地址,对吗?