How many peer connections can I create on a single client? Is there any limit?
As many as you like. You can cram anywhere from one to a million users into a WebRTC call.
WebRTC is designed to work peer-to-peer, so users can connect by the most direct route possible. However, WebRTC is built to cope with real-world networking: client applications need to traverse NAT gateways and firewalls, and peer to peer networking needs fallbacks in case direct connection fails.
Peer connections is the part of the WebRTC specifications that deals with connecting two applications on different computers to communicate using a peer-to-peer protocol. The communication between peers can be video, audio or arbitrary binary data (for clients supporting the RTCDataChannel API).
I assume you've arrived at 256 experimentally since there is currently no documentation/specs to suggest it. I don't know exactly how things have changed since 2013, but currently, my own experiments cap out at 500 simultaneous connections per page. As far as I can tell, Firefox has no such limit.
The real limit, according to Chromium source code is 500 (source). As far as I can tell, there was no limit before this was implemented (source) even going as far back as the WebKit days.
I think one reason that it can be tricky to keep track of is that Chrome (and FF for that matter) have always been bad at the garbage collection of dead connections. If you check chrome://webrtc-internals
(FF equivalent: about:webrtc
), there will often be a build-up of zombie connections that count towards the 500 limit. These persist until you manually destroy them, or close/refresh the page. One way to work around this is through your own heartbeat implementation or using the signalling server to notify of peers disconnecting such that other peers can destroy their connection (although this requires a persistent connection to a signalling server).
Maximum peer connections limit is 256 (on chrome).
Not sure about other major browsers, depending on your bandwidth they are limited to give certain stability.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With