0

I am using webrtc in my project. But when the RTCPeerConnection.iceConnectionState='closed' it is not being removed from browser (Google Chrome 67.0.3396.99) .

I have used RTCPeerConnection.close() and after that I am setting the connection object to null. But still it is being showed in chrome://webrtc-internals/. The problem is that there can be too many connections in my application, so when the connections are not cleared, I am not able to create any new connection after some time. It is showing too many connection error in my application. Can someone please help me resolving the issue?

Thanks

3 Answers3

3

This is a long standing problem in Chrome that I've been keeping track of. RTCPeerConnection do not get garbage collected in a timely manner. I've noticed over time, especially when switching between tabs, RTCPeerConnection do eventually get garbage collected.

The limit seems to be 500 connections, so just try to limit the amount of connections you make.

Here are some links that reference this bug:

https://bugs.chromium.org/p/chromium/issues/detail?id=825576 https://bugs.chromium.org/p/chromium/issues/detail?id=429600

EDIT:

A hacky solution could be to create connections in an iframe. I remember the connections were GC'd when the iframe was deleted.

Eric Guan
  • 15,474
  • 8
  • 50
  • 61
0

Well I guess that's a feature, meant to allow you to inspect your connections afterwards.

They seem to be removed immediately when I close or reload the tab that had the connection. Probably the same reason the iframe trick mentioned by Eric Guan works.

kiw
  • 748
  • 1
  • 9
  • 18
-2

For webrtc you should use a websocket server, browsers by default only allow a limit amount of conections per client, it's not server limit, it's browser limit.

also you are probably seeing RTCPeerConnection.iceConnectionState='closed' because you need to build a signaling server, orther wise webrtc won't open conections, websockets is a very used solution to build a signaling server, see a example

Otávio Barreto
  • 1,536
  • 3
  • 16
  • 35
  • When I am going to close the connection, still it shows in webrtc-internals of the chrome browser. My issue is that it is still showing the closed connection even after made it null and stop all it reference. I want a solution that will close the rtcpeerconnection of webrtc and remove it from the browser webrtc-internals as soon I closed it. – LATA KIRAN Aug 17 '19 at 17:17
  • you need to send webrtc data via a signaling server, you can use a signaling server, or build your own using websockets, by your question it looks you are only running webrtc client – Otávio Barreto Aug 17 '19 at 17:28