Search code examples
webrtcice

ICE candidates gathered only from one network interface


Got very simple code:

<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>

Got ubuntu running chromium and TWO local ethernet interfaces. Running aforementioned code yields only 1 call to onicecandidate and 1 call to onicegatheringstatechange. (any STUN/TURN servers are deliberately not specified, so I do expect only local host candidates, but from all interfaces). Only one ethernet interface is examined by ICE.

Why ?


Solution

  • Unless you have permissions for getUserMedia, Chrome will restrict ICE candidates to the interface of the default route. The rationale is explained in this draft