Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

I created 4 rooms for 1 peer, and encountered errors: Cannot create so many PeerConnections #81

Open
warrenchopin opened this issue Jul 12, 2024 · 2 comments

Comments

@warrenchopin
Copy link

warrenchopin commented Jul 12, 2024

Hi,

I just have integrated Tystero in default setting. It worked ok with 1 room for two peers. So, to extend further, I created 4 rooms for one peer, and the following error was thrown over thousands times repeatedly.

trystero-torrent.min.js:1 Uncaught DOMException: Failed to construct 'RTCPeerConnection': Cannot create so many PeerConnections
    at new e (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:30533)
    at new It (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:43470)
    at jt (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:46528)
    at U (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:48201)
    at Array.map (<anonymous>)
    at t (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:45)
    at $ (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:48382)
    at d (http://localhost:9999/lib/network/trystero/v0.19.0/trystero-torrent.min.js:1:54961)

I don't understand that the error message complains about "so many PeerConnections". I just created 4 rooms for only one peer. Is creating multiple rooms not allowed for a single peer?

I really appreciate your help. Thanks in advance.

@dmotz
Copy link
Owner

dmotz commented Jul 13, 2024

For now, try using a different strategy like Nostr or MQTT, which are less prone to this issue. I'm investigating a fix for this.

The following explains why this happens if you're curious:

You've come across some behavior that's caused by a long-open Chrome bug which prevents old peer connections from being garbage collected. Chrome caps the number of connection objects to 500 which wouldn't normally cause a problem as Trystero cleans up stale connection instances, but due to this bug they're not correctly cleaned up by Chrome.

Why are so many peer connections created? The torrent strategy periodically creates a batch of peers and broadcasts their associated offers to the tracker. Over time these compound and without proper GC, they hit the limit (faster if multiple rooms are open).

@warrenchopin
Copy link
Author

Thanks for your reply. I am developing a 3d web game, and trying to develop as a multi player game.

I need 9 rooms to allow peer players move in the surrounding space of the main player. My game space has extendable lands where new nearby lands are opened when the player crossing (or approaching) the border.

I can figure out to reduce the requires number of rooms to 6, 5, or 4 (maybe or less). But, the complexity of algorithm increases and smoothness of surrounding space decreases as the number of room decreases.

Do you think that Trysteo will be able to support to join 9 rooms after fix? Is there a recommended maximum number of rooms to open without significantly undermining efficiency of the communication system?

Thanks again.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants