Not receiving any ICE candidates

None of the ICE related callbacks are being triggered ever. I am running these tests on an iOS simulator.

My understanding is that ICE candidates would be fetched after setting local description.

Here is my code

const pc = new RTCPeerConnection({
  iceServers: [{ url: '' }],

pc.onicegatheringstatechange = () => {

pc.onicecandidate = ({ candidate }) => {
  console.log('got a candidate', candidate);

pc.onicecandidateerror = error => {

pc.oniceconnectionstatechange = evt => {

const description = await pc.createOffer();
await pc.setLocalDescription(description);

I have also tried setting remote description, nothing.

If you add a media stream to the peer, do the events then trigger properly?

Yes that fixed it. Specifically I have to add the stream before adding the local description. Thanks.

1 Like

No worries :smile:
You should also be able to get things going by attempting the creation of a data channel.
If you don’t want to send video/voice streams.

Helo, How do u add a media stream to a peer ? ?I haven’t been able to do that.

I actually added the local stream and I still got no ice candidate

Would be worth going over some docs as to how the module functions.
Theres some basic examples on here.
But what you would do is run mediaDevices.getUserMedia(); and then grab the result which would be the desired stream variable and then feed it into the peer connection via peerConnection.addStream( localStream );

Hey thank you I was able to get it to work !!

Iceconnectionstate is remaining @ chaeking, I dont get called onaddstream too.
But I have exchanged descriptions and icecandidate properly . Please help me

Late response but for anyone having the issue where your ice connection state gets stuck on checking you might want to check your stun and turn servers are working correctly.