Webrtc ICE候选者仅从一个网络接口收集

Webrtc ICE候选者仅从一个网络接口收集,webrtc,ice,Webrtc,Ice,得到了非常简单的代码: <script type="text/javascript"> pc = new window.RTCPeerConnection(); pc.onicecandidate = function(event) { console.log("onicecandidate\n", event); } pc.onicegatheringstatechange = function(event) {

得到了非常简单的代码:

<script type="text/javascript">
    pc = new window.RTCPeerConnection();

    pc.onicecandidate = function(event) {
        console.log("onicecandidate\n", event);
    }

    pc.onicegatheringstatechange = function(event) {
        console.log("onicegatheringstatechange\n", event);
    }

    dc = pc.createDataChannel("dataChannel");

    errFunc = function(err) {
        console.log("errFunc\n", err);
    }

    successCback = function() {
        console.log("setLocalDescription is a success\n");
    }

    pc.createOffer()
        .then(function(offer) { pc.setLocalDescription(offer)})
        .then(successCback)
        .catch(errFunc);

</script>

pc=新窗口。RTPeerConnection();
pc.onicecandidate=函数(事件){
console.log(“onicecandidate\n”,事件);
}
pc.oginegatheringstatechange=函数(事件){
console.log(“onicegatheringstatechange\n”,事件);
}
dc=pc.createDataChannel(“数据通道”);
errFunc=函数(err){
console.log(“errFunc\n”,err);
}
successCback=函数(){
log(“setLocalDescription是成功的\n”);
}
pc.createOffer()
.then(函数(提供){pc.setLocalDescription(提供)})
.然后(成功返回)
.catch(errFunc);
ubuntu运行chromium和两个本地以太网接口。 运行上述代码只会产生1调用onicecandidate和 1调用OniceAgheringStateChange。(故意不指定任何晕眩/转弯服务器,因此我只希望本地主机候选,但从所有接口)。ICE只检查一个以太网接口


为什么?

除非您拥有getUserMedia的权限,否则Chrome会将ICE候选对象限制在默认路由的接口上。解释了理由

非常感谢,@Philipp。看来这是个案子。但我在这里有点迷茫——我想创建一个仅数据通道的peerconnection(因此我不需要getUserMedia请求),并从所有网络接口获得候选接口。有没有可行的方法可以做到这一点?@psb简单的回答是没有,而且将来可能会变得更糟。加入我们的努力,实现专门的许可请求。