How to clear RTCPeerConnection (WebRTC)?
Asked Answered
H

1

5

Has anyone seen that error, literally:

"Uncaught DOMException: Failed to construct 'RTCPeerConnection': Cannot create so many PeerConnections"?

I guess it's happens because I didn't removed connections (maybe not, maybe it's because I didn't provide more memory or something). But from where? Where do they accumulate?

I didn't found answer for the question, literally, nowhere.

I was tried to solve that problem a couple days. By the way, no such thing as a stupid question, right?

UPD: Forgot to add that I using sip.js library.

Hackamore answered 28/3, 2018 at 11:9 Comment(2)
Without a bit more code is difficult to guess where the error may be. There is an answer related to maximum number of RTCPeerConnections #41195045Hyperacidity
Possible duplicate of Maximum number of RTCPeerConnectionHyperacidity
H
7

Found and fixed the problem. Sip.js library has a .close() method that closes the peerConnection. But this is not enough for a garbage collector. Object peerConnection should be reset to null.

So, the solving was adding two new lines in library, like

this.mediaHandler.peerConnection = null

and that's it. WebRTC is not crowded and all are happy.

Hackamore answered 4/4, 2018 at 6:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.