Search code examples
javascriptgoogle-chromefirefoxwebrtcgetusermedia

How to fully close a WebRTC connection


When I am trying to close the WebRTC connection after a call using rtc.close(), I recognize that about:webrtc-internals in Chrome and about:webrtc keep the connections listed. In Firefox, they are marked as closed, while in Chrome I could not see such a denotation.

I am asking because this seems to have a significant performance impact after some time. After having done a lot of calls, the performance is significantly impaired and webrtc-internals lists a large number of connections.

Is there anything more to closing a WebRTC connection than .close() to make the browser fully forget about the connection?


Solution

  • You should see the peer connection go to ICEConnectionStateClosed and SignalingStateClosed. One thing that you should do is ensure that you're stopping all local media stream tracks. If you don't, the browser will keep them open, because they aren't closed when a peer connection is closed.

    pc closed