Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC: ICE failed since Firefox v 53

Tags:

webrtc

I got a problem with my webRTC-project. My code works well at Chrome and Firefox until version 52. Since Firefox 53 i got the error: "ICE failed, see about:webrtc for more details". This is my code:

let connection;
let dataChannel;

 const initCon = (initiatorBoolean, choosenONE) => {
     createConnection();
     startConnection(initiatorBoolean, choosenONE);
     console.log('initCon(' + initiatorBoolean + ') / choosenONE = ' +choosenONE);
 }
var boolJoin =  false;
var lobbies = [];
var me = prompt("Please enter your name", "Bert");


// Helper für das Errorlogging
const logErrors = err => console.log(err);

// Websockets-Verbindung herstellen
const socket = io.connect('http://7daysclub.de:8080');

/* Methode to send information between to Users
*@param
*receiver= User who get the message
*type= Type of the message: could be init, joined, getUsers, setUsers, offer, answer, candidate
*descr= Content of the message
*/
 const sendMessage = (receiver, type, descr) => {
   message = Object.assign({to: 'default'}, {
       user: receiver,
       type: type,
       descr: descr,
       from: me
   });
   socket.emit('message', message);
   console.log("send: " + message.type + ". to: " + message.user);
};

const createConnection = () => {
    //Verbindung erstellen
    connection = new RTCPeerConnection( {
    'iceServers': [
        {

          /*
          'urls': 'stun:stun.l.google.com:19302'
          */
          'urls': 'stun:185.223.29.90:3478'


        },
        {

          'urls': 'turn:185.223.29.90:3478',
          'credential': '***',
          'username': '***'


        }
    ]
    });
    connection.oniceconnectionstatechange = function(event) {
      console.log('state: '+connection.iceConnectionState );
      if (connection.iceConnectionState === "failed" ||
          connection.iceConnectionState === "disconnected" ||
          connection.iceConnectionState === "closed") {
        // Handle the failure
      }
    };

}

const call = choosenONE => {

    if (!boolJoin) {
        sendMessage(choosenONE, 'joined', null);
    }

};

// Nachricht vom Signaling-Kanal empfangen
const receiveMessage = message => {
   console.log("receive: " + message.type);

   //Filter messages
   if (message.user != 'all' && message.user != me) {
       console.log("Block= " + message.user);
       return;
   }
   // Nachricht verarbeiten
   switch (message.type) {

       // Partner ist verfügbar
      case 'joined':
         choosenONE = message.from;
         sendMessage( choosenONE, 'init', null);
         boolJoin = true;
         initCon(true, choosenONE);
         break;

      case 'getUsers':
         sendMessage(message.from,'setUsers', null)
         lobbies.push(message.from);
         lobbylist();
         console.log('add User: ' + lobbies[lobbies.length-1] + ' to List');
         break;

      case 'setUsers':
         lobbies.push(message.from);
         console.log('add User: ' + lobbies[lobbies.length-1] + ' to List');
         lobbylist();
         break;

      // Verbindungsaufbau wurde vom Partner angefordert
      case 'init':
         choosenONE = message.from;
         boolJoin = true;
         initCon(false, choosenONE);
         break;


      // Ein SDP-Verbindungsangebot ist eingegangen – wir erstellen eine Antwort
      case 'offer':
        connection
          .setRemoteDescription(new RTCSessionDescription(message.descr))
          .then(() => connection.createAnswer())
          .then(answer => connection.setLocalDescription(new RTCSessionDescription(answer)))
          .then(() => sendMessage(message.from,'answer', connection.localDescription, me))
          .catch(logErrors);
         break;

      // Eine SDP-Verbindungsantwort auf unsere Anfrage ist eingegangen.
      case 'answer':
         connection.setRemoteDescription(new RTCSessionDescription(message.descr));
         break;

      // Der Partner hat eine mögliche Host-Port-Kombination ("ICE Candidate") gefunden
      case 'candidate':
         connection.addIceCandidate(new RTCIceCandidate({candidate: message.descr}));
         break;
   }
};

socket.on('message', receiveMessage);



// Verbindung initialisieren
const startConnection = (isCreator, choosenONE) => {
    // Wenn wir mögliche Kommunikationsendpunkte finden, diese an den Partner weitergeben
    connection.onicecandidate = event => {
        if (event.candidate) {
            sendMessage(choosenONE, 'candidate', event.candidate.candidate);
        }
    };

    // Wenn die Gegenseite einen Stream hinzufügt, diesen an das video-element hängen
   connection.ontrack = (e) => {
      document.getElementById('vidRemote').src = window.URL.createObjectURL(e.stream);
   };

   // Falls wir der erste Teilnehmer sind, starten wir den Verbindungsaufbau
   if (isCreator) {
      // Datenkanal anlegen
      dataChannel = connection.createDataChannel('chat');
      onDataChannelCreated(dataChannel);

      connection
        .createOffer()
        .then(offer => connection.setLocalDescription(new RTCSessionDescription(offer)))
        .then(() => sendMessage(choosenONE, 'offer', connection.localDescription))
        .catch(logErrors);

   } else {

      // Wenn wir nicht der Initiator sind, reagieren wir nur auf das Anlegen eines Datenkanals
      connection.ondatachannel = function (event) {
         dataChannel = event.channel;
         onDataChannelCreated(dataChannel);
      };

   }
};



const onDataChannelCreated = (channel, choosenONE) => {
   // Sobald der Datenkanal verfügbar ist, Chateingaben zulassen
   channel.onopen = () => {
      const enterChat = document.getElementById('enterChat');
      enterChat.disabled = false;
      enterChat.onkeyup = (keyevent) => {
         // Bei "Enter" absenden
         if (keyevent.keyCode === 13) {
            dataChannel.send(enterChat.value);
            appendChatMessage(me+':', enterChat.value);
            enterChat.value = '';
         }
      }
   };
   channel.onmessage = (message) => appendChatMessage(choosenONE+':', message.data);
};

const appendChatMessage = (name, text) => {
   const displayChat = document.getElementById('displayChat');
   const time = new Date().toString('H:i:s');
   displayChat.innerHTML = `<p>${name} - ${time}<br>${text}</p>` + displayChat.innerHTML;
};



function lobbylist() {
    allusers = "";
    lobbies.forEach( element => {
        allusers += "<li><button onclick=\"call('"+element+"')\">"+element+"</button></li>"
    });
    document.getElementById('lobbylist').innerHTML = allusers;
}

//Alle User bei Ankunft erfragen
sendMessage('all','getUsers', null);
lobbylist();

And about:webrtc =

(registry/INFO) insert 'ice' (registry) succeeded: ice

(registry/INFO) insert 'ice.pref' (registry) succeeded: ice.pref

(registry/INFO) insert 'ice.pref.type' (registry) succeeded: ice.pref.type

(registry/INFO) insert 'ice.pref.type.srv_rflx' (UCHAR) succeeded: 0x64

(registry/INFO) insert 'ice.pref.type.peer_rflx' (UCHAR) succeeded: 0x6e

(registry/INFO) insert 'ice.pref.type.host' (UCHAR) succeeded: 0x7e

(registry/INFO) insert 'ice.pref.type.relayed' (UCHAR) succeeded: 0x05

(registry/INFO) insert 'ice.pref.type.srv_rflx_tcp' (UCHAR) succeeded: 0x63

(registry/INFO) insert 'ice.pref.type.peer_rflx_tcp' (UCHAR) succeeded: 0x6d

(registry/INFO) insert 'ice.pref.type.host_tcp' (UCHAR) succeeded: 0x7d

(registry/INFO) insert 'ice.pref.type.relayed_tcp' (UCHAR) succeeded: 0x00

(registry/INFO) insert 'stun' (registry) succeeded: stun

(registry/INFO) insert 'stun.client' (registry) succeeded: stun.client

(registry/INFO) insert 'stun.client.maximum_transmits' (UINT4) succeeded: 7

(registry/INFO) insert 'ice.trickle_grace_period' (UINT4) succeeded: 5000

(registry/INFO) insert 'ice.tcp' (registry) succeeded: ice.tcp

(registry/INFO) insert 'ice.tcp.so_sock_count' (INT4) succeeded: 0

(registry/INFO) insert 'ice.tcp.listen_backlog' (INT4) succeeded: 10

(registry/INFO) insert 'ice.tcp.disable' (char) succeeded: \000

(generic/EMERG) Exit UDP socket connected

(generic/ERR) UDP socket error:Internal error at z:/build/build/src/dom/network/UDPSocketParent.cpp:283 this=00000000120CC400

(ice/INFO) z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173 function nr_socket_multi_tcp_create_stun_server_socket skipping UDP STUN server(addr:IP4:185.223.29.90:3478/UDP)

(ice/INFO) z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173 function nr_socket_multi_tcp_create_stun_server_socket skipping UDP STUN server(addr:IP4:185.223.29.90:3478/UDP)

(ice/WARNING) z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:617 function nr_socket_multi_tcp_listen failed with error 3

(ice/WARNING) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): failed to create passive TCP host candidate: 3

(ice/NOTICE) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) no streams with non-empty check lists

(ice/NOTICE) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) no streams with pre-answer requests

(ice/NOTICE) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) no checks to start

(ice/ERR) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate host(IP4:192.168.0.4:54605/UDP)

(ice/ERR) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate host(IP4:192.168.0.4:62417/TCP) active

(stun/INFO) Unrecognized attribute: 0x802b

(stun/INFO) STUN-CLIENT(srflx(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)): Received response; processing

(ice/ERR) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate srflx(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)

(stun/INFO) STUN-CLIENT(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Received response; processing

(stun/WARNING) STUN-CLIENT(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Error processing response: Retry may be possible, stun error code 401.

(stun/INFO) STUN-CLIENT(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Received response; processing

(stun/WARNING) STUN-CLIENT(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Error processing response: Retry may be possible, stun error code 401.

(turn/WARNING) TURN(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)): Exceeded the number of retries

(turn/WARNING) TURN(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)): mode 20, nr_turn_client_error_cb

(turn/WARNING) TURN(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)) failed

(turn/INFO) TURN(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)): cancelling

(turn/WARNING) ICE-CANDIDATE(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)): nr_turn_allocated_cb called with state 4

(turn/WARNING) ICE-CANDIDATE(relay(IP4:192.168.0.4:54605/UDP|IP4:185.223.29.90:3478/UDP)): nr_turn_allocated_cb failed

(ice/INFO) ICE(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/)): peer (PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default) Trickle grace period is over; marking every component with only failed pairs as failed.

(ice/INFO) ICE-PEER(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default)/STREAM(0-1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/) aLevel=0)/COMP(1): All pairs are failed, and grace period has elapsed. Marking component as failed.

(ice/INFO) ICE-PEER(PC:1512241952789000 (id=19327352835 url=http://7daysclub.de/webrtc2/):default): all checks completed success=0 fail=1

(generic/EMERG) Exit UDP socket connected

(generic/ERR) UDP socket error:Internal error at z:/build/build/src/dom/network/UDPSocketParent.cpp:283 this=000000000BAE3000

(ice/INFO) z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173 function nr_socket_multi_tcp_create_stun_server_socket skipping UDP STUN server(addr:IP4:185.223.29.90:3478/UDP)

(ice/INFO) z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:173 function nr_socket_multi_tcp_create_stun_server_socket skipping UDP STUN server(addr:IP4:185.223.29.90:3478/UDP)

(ice/WARNING) z:/build/build/src/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c:617 function nr_socket_multi_tcp_listen failed with error 3

(ice/WARNING) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): failed to create passive TCP host candidate: 3

(ice/NOTICE) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) no streams with non-empty check lists

(ice/NOTICE) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) no streams with pre-answer requests

(ice/NOTICE) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) no checks to start

(ice/ERR) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate host(IP4:192.168.0.4:63286/UDP)

(ice/ERR) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate host(IP4:192.168.0.4:54433/TCP) active

(stun/INFO) Unrecognized attribute: 0x802b

(stun/INFO) STUN-CLIENT(srflx(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:3478/UDP)): Received response; processing

(ice/ERR) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate srflx(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:3478/UDP)

(stun/INFO) STUN-CLIENT(relay(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Received response; processing

(stun/WARNING) STUN-CLIENT(relay(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Error processing response: Retry may be possible, stun error code 401.

(stun/INFO) STUN-CLIENT(relay(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:3478/UDP)::TURN): Received response; processing

(turn/INFO) TURN(relay(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:3478/UDP)): Succesfully allocated addr IP4:185.223.29.90:50497/UDP lifetime=3600

(ice/ERR) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) pairing local trickle ICE candidate turn-relay(IP4:192.168.0.4:63286/UDP|IP4:185.223.29.90:50497/UDP)

(ice/INFO) ICE(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/)): peer (PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default) Trickle grace period is over; marking every component with only failed pairs as failed.

(ice/INFO) ICE-PEER(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default)/STREAM(0-1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/) aLevel=0)/COMP(1): All pairs are failed, and grace period has elapsed. Marking component as failed.

(ice/INFO) ICE-PEER(PC:1512242125375000 (id=19327352836 url=http://7daysclub.de/webrtc2/):default): all checks completed success=0 fail=1

+++++++ END ++++++++

And my turnserver config looks like this:

# TURN listener port for UDP and TCP (Default: 3478).
# Note: actually, TLS & DTLS sessions can connect to the 
# "plain" TCP & UDP port(s), too - if allowed by configuration.
#
listening-port=3478

# TURN listener port for TLS (Default: 5349).
# Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
# port(s), too - if allowed by configuration. The TURN server 
# "automatically" recognizes the type of traffic. Actually, two listening
# endpoints (the "plain" one and the "tls" one) are equivalent in terms of
# functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
# For secure TCP connections, we currently support SSL version 3 and 
# TLS version 1.0, 1.1 and 1.2. SSL2 "encapculation mode" is also supported.
# For secure UDP connections, we support DTLS version 1.
#
tls-listening-port=5349

# Listener IP address of relay server. Multiple listeners can be specified.
# If no IP(s) specified in the config file or in the command line options, 
# then all IPv4 and IPv6 system IPs will be used for listening.
#
listening-ip=185.223.29.90

# Relay address (the local IP address that will be used to relay the 
# packets to the peer).
# Multiple relay addresses may be used.
# The same IP(s) can be used as both listening IP(s) and relay IP(s).
#
# If no relay IP(s) specified, then the turnserver will apply the default
# policy: it will decide itself which relay addresses to be used, and it 
# will always be using the client socket IP address as the relay IP address
# of the TURN session (if the requested relay address family is the same
# as the family of the client socket).
#
relay-ip=185.223.29.90


lt-cred-mech


# Realm for long-term credentials mechanism and for TURN REST API.
#
realm=7daysclub.de


#Local system IP address to be used for CLI server endpoint. Default value
# is 127.0.0.1.
#
cli-ip=185.223.29.90

# CLI server port. Default is 5766.
#
cli-port=5766
like image 864
J03M4gnus Avatar asked Dec 02 '17 20:12

J03M4gnus


1 Answers

Looking at your online demo there is no a=candidate line in the remote SDP which suggests the candidate is never added. sendMessage(choosenONE, 'candidate', event.candidate.candidate); this is discarding the sdpMid and sdpMLineIndex which needs to be signalled to the remote peer. Add a .catch to your addIceCandidate to log any errors.

like image 149
Philipp Hancke Avatar answered Nov 12 '22 00:11

Philipp Hancke