Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating ICE Candidates

Tags:

webrtc

I am working WebRTC API's to make a video call between two PC's running on chrome browser. My observation is ICE Candidates are generated only if i connected to internet else no ice candidates are generated. Why is it like that?

connection block

var pc_config = {"iceServers":[]};

      pc = new webkitRTCPeerConnection(pc_config);
       pc.onicecandidate=function (evt) {

       if(evt.candidate){
         console.log("Sending candidate to other peer"+evt);
        jWebSocketClient.broadcastText("",evt);
        }
      };  

Thanks, Sureshkumar Menon

like image 511
Sureshkumar Menon Avatar asked Feb 14 '23 12:02

Sureshkumar Menon


1 Answers

As far as I understand, there is four types of ICE candidate :

  1. Host candidate : from your local interface.
  2. Server reflexive candidate : provided by the STUN server, a translation of your local address into public network.
  3. Relayed candidate : provided by a TURN server, data will be relayed by the server
  4. Peer reflexive candidate : a rare case (?) where candidate is discovered during the connectivity checks. I'll skip this part as it is quite rare and I'm not sure to understand the big picture of it.

If you don't provide any STUN / TURN addresses to your program or if they are unreachable, the only candidate which can be retrieved is the host one. Note that your local address (127.0.0.1) is not taken as a potential candidate. Hope it helps.

However, I'm not totally sure to understand your use case.. Are both computers on the same local network ? If your interface is up, you should get at least the host candidate. I only worked with the C++ API, but I don't see why it would have a different behavior with the Javascript's.

like image 100
ZaX Avatar answered Mar 03 '23 15:03

ZaX