DOMException: Error processing ICE candidate
This error can also occur if you attempt to connected to your own peer (local) id.
This problem is almost totally undocumented, and to make matters worse only Google seems to be implementing the w3 webRTC standard. They also deviate from this standard.
However, as it is most likely that this will be occurring on Chrome (I have not checked Firefox, and Safari does not implement getUserMedia()
), this error message obtained by launching Chrome from the console will likely help:
[ERROR:rtc_peer_connection_handler.cc(1439)] Error processing ICE candidate.
[ERROR:webrtcsession.cc(1134)] ProcessIceMessage: ICE candidates can't be added without any remote session description.
So there, you can't add ICE candidates without setting remote description as according to the most recent build of Chrome, and as it is 2017 with no webRTC progress except for Facebook Messenger, this looks to be valid for the foreseeable future.
So remember to call
if(!peerConnection || !peerConnection.remoteDescription.type){
//push candidate onto queue...
}
and after setting the remote description, iterate the queue to add candidates with the peer connection in the right state!
If you're keeping more than one RTCPeerConnection
object around, you must make sure you're adding the ICE candidates and descriptions to the correct one.