RTCPeerConnection state change events not firing for some state changes

348 views
Skip to first unread message

Maxwell Mooney

unread,
Jul 11, 2023, 10:25:22 AM7/11/23
to discuss-webrtc
Hi all,

We're using the RTCPeerConnection object in one of our services and reacting to some of the events in particular connectionstatechange and iceconnectionstatechange. We noticed that these events seem to fire for "connecting"/"connected" and "checking"/"connected" respectively but not any other events.  I found in some documentation that the events don't fire in the case of "closed."  So I was wondering is there a reason behind this?  If so and there's no intent on changing, is there a way for third party consumers to know when a connection disconnects or closes so that we can react accordingly?

Thank you in advance.

Philipp Hancke

unread,
Jul 11, 2023, 10:30:56 AM7/11/23
to discuss...@googlegroups.com
From what I can see they fire as intended on
  https://webrtc.github.io/samples/src/content/peerconnection/bandwidth/
if you add event listeners
pc1.addEventListener('connectionstatechange', () => console.log('C', pc1.connectionState));
pc1.addEventListener('iceconnectionstatechange', () => console.log('I', pc1.iceConnectionState))
and then close the second peerconnection with
pc2.close()

If you are seeing something else you might want to cross-check with chrome://webrtc-internals
Calling close won't fire events (on the same connection) since it is a user-triggered action.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/9b61248e-82b1-487b-992a-8a70ab827305n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages