dmotz / trystero

✨🤝✨ Build instant multiplayer webapps, no server required — Magic WebRTC matchmaking over BitTorrent, Nostr, MQTT, IPFS, Supabase, and Firebase
https://oxism.com/trystero
MIT License
1.13k stars 85 forks source link

Reconnection Logic #2

Closed lmangani closed 3 years ago

lmangani commented 3 years ago

Wonderful little library you're building here!

I was playing with the demo and comparing it to our DAM/GUN approach using the bittorrent strategy, and while everything seems to work as advertised once the mesh is established, I noticed the bittorrent websocket connections are quite fragile and close quite quickly, without an obvious reconnection logic to restart announceAll and staying advertised to the trackers

WebSocket is already in CLOSING or CLOSED state.
announce @ torrent.js:102

The immediate effects is peers are not discovered when they join the page far apart in time. Did i miss anything obvious for those scenarios and/or can one be discussed to form a code contribution?

Thanks!

dmotz commented 3 years ago

Thanks for bringing this to my attention! I had reconnect logic in the torrent strategy but a small bug prevented it from ever being called. I just pushed 0.7.8 to npm which should fix the issue.

lmangani commented 3 years ago

this seems have done the trick! thanks @dmotz