30

I get this error DOMException: Error processing ICE candidate when I try to add an ice candidate. Here's the candidate:

candidate:1278028030 1 udp 2122260223 10.0.18.123 62694 typ host generation 0 ufrag eGOGlVCnFLZYKTsc network-id 1

Moreover, it doesn't always happen - other time everything goes smoothly. I can't reproduce a consistent pattern where it would throw this error. Any ideas how to go about solving this / debugging it would be appreciated!

Evaldas Raisutis
  • 1,628
  • 4
  • 18
  • 32

7 Answers7

55

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!

lol
  • 3,910
  • 2
  • 37
  • 40
  • That really helped. I created an empty array and then when I detect new-ice-candidate on the client I check if there's no peer connection. If there isn't one, I push the candidate onto the array. Then in the video offer and video answer methods, after I setRemoteDescription I add the candidates from the array like so: if (candidatesOnQueue.length > 0) { candidatesOnQueue.forEach(function(c) { myPeerConnection.addIceCandidate(c) .catch((err) => { logError(err.message); })}); } – iBobb Jul 06 '19 at 21:34
  • 3
    Why do you check for `!peerConnection.remoteDescription.type`? I believe `!peerConnection.remoteDescription` is the correct check here. The `.remoteDescription` property is possibly null. The `.type` property is a non-nullable string – jameshfisher Oct 12 '20 at 14:02
  • This is exactly what happen to me! Solved it by queuing candidates on receive and only add them after remote description has been set. Only problem is, now I have to make sure after remote description has actually been set, new candidates arriving skips the queue and go straight to ```addIceCandidate()```. Thanks! – bluearth May 27 '21 at 18:08
5

This error can also occur if you attempt to connected to your own peer (local) id.

Steve Dekorte
  • 79
  • 1
  • 4
3

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.

fiatjaf
  • 11,479
  • 5
  • 56
  • 72
2

If I make a second round of offer-answer, it works. I'm not sure why this is necessary though.

Evaldas Raisutis
  • 1,628
  • 4
  • 18
  • 32
2

This may be outdated, but i had the same error,

On Chrome i got DOMException: Error processing ICE candidate,

On Firefox, there was an error that only stated DOMException.

The additional message was: "Invalid candidate (both sdpMid and sdpMLineIndex are null).", and that was exactly the case, i really did not use them from the response i got from the signaling server about the ice candidate.

Using those 2 values when i received the signal stopped this error from happening again.

Hope this helps someone else.

Peshou
  • 66
  • 6
1

Are you adding the candidate before calling setRemoteDescription? Firefox 36 had an issue where it sent candidates before the remote description but that has been solved long since.

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31
1

In case anyone is still looking for answers, the issue with me was that my UI was trying to addIceCandidate before the localDescription had been set (remember peerConnection.createAnswer()). My caller was sending back-to-back ICE candidates but all of them were failing on the recipient's end with the error: DOMException: Error processing ICE candidate.This simple if fixed it for me:

// on receive-candidate
...
if (peerConnection.localDescription) {
    peerConnection.addIceCandidate(new RTCIceCandidate(candidate))
        .catch(error => console.log(error));
}
Ishwor Timilsina
  • 1,344
  • 12
  • 11