How to clear RTCPeerConnection (WebRTC)?

霸气de小男生 提交于 2019-12-24 17:19:26

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/49532939/how-to-clear-rtcpeerconnection-webrtc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!