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);
});
}
}