Skip to content
Advertisement

How to know when a browser peer is disconnected in aiortc?

JavaScript

Error:

JavaScript

It’s the first property in the documentation of aiortc but i cannot retrieved it.

Note: I also tried with connectionstatechange event but either that worked.

Edit: That’s the methods the pc object has:

JavaScript

Advertisement

Answer

aiortc uses pyee for making aiortc event-driven and as you can see in the official GitHub example (webcam/webcam.py), you must put an event listener on an event named iceconnectionstatechange.

Checkout the code snippet below:

JavaScript

In your question you mentioned that you’ve tried connectionstatechange event but it’s actually iceconnectionstatechange and that’s why it didn’t work the first time.

Advertisement