'RTCPeerConnection': Cannot create so many PeerConnections
See original GitHub issueHello everyone
I’m trying to create a multiplayer game in phaser. Once the game has been created i have two player. When i move my player (green) I can see the movement in a new page of my browser (not green).
Everything works for the best. But considering that the number of movements is high, after some time you get this error:
VM2455:300 Uncaught DOMException: Failed to construct 'RTCPeerConnection': Cannot create so many PeerConnections at new WrappedRTCPeerConnection (<anonymous>:300:28) at Object.m._startPeerConnection (http://localhost/SP2P/lib/peer.js:1:33131) at Object.m._getPeerConnection (http://localhost/SP2P/lib/peer.js:1:32849) at Object.m.startConnection (http://localhost/SP2P/lib/peer.js:1:32216) at new d (http://localhost/SP2P/lib/peer.js:1:2579) at p.connect (http://localhost/SP2P/lib/peer.js:1:25072) at PeerClient.conn (http://localhost/SP2P/P2P/PeerClient.js:100:27) at Object.P2PMaze.send (http://localhost/SP2P/js/GameMultiplayer.js:42:29) at P2PMaze.GameMultiplayer.update (http://localhost/SP2P/js/GameMultiplayer.js:236:21) at Phaser.StateManager.update (http://localhost/SP2P/lib/phaser.js:31183:39)
Peerjs Version: 0.3.9 Chrome version: 67.0.3396.62
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (7 by maintainers)

Top Related StackOverflow Question
I confirm that with the second solution I avoid the error. For this, now I have only two connection:
The second solution would be much recommended. The first one will give you a lot of troubles because you are creating a lot of connections, one per message, and that will not only lead you to the first error you got from PeerJS, but it will also beat your resources (cpu, ram, network)