最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to clear RTCPeerConnection (WebRTC)? - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question edited Apr 4, 2018 at 6:46 Alexander Shtang asked Mar 28, 2018 at 11:09 Alexander ShtangAlexander Shtang 1,9594 gold badges16 silver badges24 bronze badges 2
  • 1 Without a bit more code is difficult to guess where the error may be. There is an answer related to maximum number of RTCPeerConnections stackoverflow./questions/41194545/… – SirPeople Commented Mar 28, 2018 at 11:13
  • Possible duplicate of Maximum number of RTCPeerConnection – SirPeople Commented Mar 28, 2018 at 11:14
Add a ment  | 

1 Answer 1

Reset to default 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.

发布评论

评论列表(0)

  1. 暂无评论