0

I've touched to Web RTC and I have to make the video chat application on web base. When I add Ice candidate, I got this error:

Uncaught SyntaxError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': The ICE candidate could not be added.

I tried to find out it and someone tell me that there's errors when ICE Candidates are received before answer is sent but dont give any solution. Could anyone please help me to solve it. Thank you so much!

Here is my code:

...

serverConnection.onmessage = gotMessageFromServer;

...

function gotMessageFromServer(message) {
if(!peerConnection) { 
        start(false);
    }

var signal = JSON.parse(message.data);
if(signal.ice) {
    peerConnection.addIceCandidate(new RTCIceCandidate(signal.ice));
} else if(signal.sdp) {
    peerConnection.setRemoteDescription(new RTCSessionDescription(signal.sdp), function() {
        peerConnection.createAnswer(gotDescription, createAnswerError);
    });
}

}

Community
  • 1
  • 1
Einsamer
  • 1
  • 1
  • 3
  • That code seems wrong. For `signal.ice` you should be calling `addIceCandidate`, not `createOffer`. See [example in the spec](http://w3c.github.io/webrtc-pc/#simple-peer-to-peer-example). You're also not showing the code that calls `addIceCandidate`, so it is hard answer. – jib Mar 22 '16 at 16:17
  • Sorry, something wrong and I copy code with mistake. I edited it, addIceCandidate and I got that above error. :) – Einsamer Mar 23 '16 at 02:05

0 Answers0