1

At the moment, I am playing around with WebRTC. My goal is to setup a datachannel between two browsers. Chrome-Chrome is working well. Now I am playing with Firefox-Firefox. Here is a MEW from my current code:

var servers = { "iceServers": [{ "url": "stun:stun.l.google.com:19302" }] };
var RTCPeerConnection = window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var SessionDescription = window.mozRTCSessionDescription || window.RTCSessionDescription;
var IceCandidate = window.mozRTCIceCandidate || window.RTCIceCandidate;

var peerConnection = new RTCPeerConnection(servers, { optional: [{ RtpDataChannels: true }] });
peerConnection.onicecandidate = function (event) {
    peerConnection.onicecandidate = null;
    console.log('ICE Candidate:', JSON.stringify(event.candidate))
};

var channel = peerConnection.createDataChannel("sendDataChannel", {reliable: false});

peerConnection.createOffer(
    function (offer) {
        peerConnection.setLocalDescription(offer);
    }, function (e) { }
);

As soon setLocalDescription is called, the function onicecandidate is called (as expected). In Chrome 36 the event.icecandidate is something like:

{"sdpMLineIndex":0,"sdpMid":"audio","candidate":"a=candidate:3430859439 1 udp 2122260223 xxx.xxx.xxx.xxx 59773 typ host generation 0\r\n"} 

In Firefox the event.icecandidate is just null. But I need to send that ICE candidate over the signaling channel to establish the connection.

Dennis
  • 4,011
  • 7
  • 36
  • 50

1 Answers1

2

Chrome fires the onicecandidate event as it supports "trickle-ice". Firefox on the other hand does not support trickle-ice. If you notice the SDP generated by Firefox, it should already contain the necessary candidate lines. The null onicecandidate event is to indicate that the ice gathering is complete (for both Chrome and Firefox) and you can send the SDP to the peer.

Deep Pai
  • 386
  • 1
  • 3
  • Thanks for your reply. I realized, that for a Chrome-Chrome connection I need the SDP *and* the ICE candidate. For a Firefox-Firefox connection *just* the SDP; so both are working well. I do not get a DataChannel between Firefox and Chrome. Do you know if it is possible yet? Here is my whole test application: https://boldt.github.io/webrtc/two-tabs/ – Dennis Aug 27 '14 at 12:05