0

I am trying to initiate peer to peer connection in webrtc. I am using signalr as signaling server. I am getting error in all the browser when adding ice candidate. Below is the error and line of code. Please let me know how can i fix this.

Error in Firefox:

InvalidStateError: No remoteDescription.

Error in Chrome:

DOMException: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': Error processing ICE candidate

Code:

if (signal.ice) {
       console.log(signal.ice);
       peerConnections.addIceCandidate(new RTCIceCandidate(signal.ice)).catch(errorHandler.message);
}
Chak
  • 13
  • 3

1 Answers1

0

You don't need to build a new ice candidate object. Just adding signal.ice as ice candidate is enough. Here is the example from the official webrtc guide

signalingChannel.addEventListener('message', async message => {
    if (message.iceCandidate) {
        try {
            await peerConnection.addIceCandidate(message.iceCandidate);
        } catch (e) {
            console.error('Error adding received ice candidate', e);
        }
    }
});
Dirk V
  • 1,373
  • 12
  • 24