connect-four
connect-four copied to clipboard
Sync failure?
If you play a game with two browser windows in the local area, it is very good. However, the game is not going well with other IP bands.
When a user creates a room in a different IP band, the room is not visible until the user manually refreshes, sometimes only after a few minutes of waiting minutes.
I don't know why games don't go smoothly in the other IP bands. Does Gun not have a flexible service Discovery like Kademla DHT? I don't understand Gun's peer search system even after reading the official document. There seems to be a great lack of information.
I haven't been involved with GunDB for a few years, but as of January 2017 there wasn't any real routing algorithm, certainly nothing as fancy as Kademlia. Each connection was considered a unique peer and packets made their way via network flooding. Peers rebroadcast and process messages based on whether the message ID exists in a volatile cache, preventing infinite rebroadcasts and identifying responses to its own requests. Surprisingly it worked well enough.
C4 is still running an old version of gun with a websocket star topology (the only method supported at the time, possibly still true). Unless there's something funky going on with the websocket connections, the data should finish propagating rather quickly with 2 hops:
- browser pushes to relay server
- server relays to all connected browsers
Then a few extra pings back and forth and a ton of acknowledgements. But the data should've already been processed by GunDB, so that should happen pretty quickly. There might be another factor playing here. GunDB introduces artificial latency when incoming data is versioned with a future timestamp by waiting until the current time reaches the declared time of the update (gun uses wall clocks to version data). The system also tries to implement it's own form of NTP, but to my knowledge Mark only tested it on LANs, so it's possible there's a bug that causes artificial clock drift resulting in those missing minutes.
But that's all a guess, and based on information that was relevant 6 major versions ago.
Unfortunately I don't have ambitions to keep this app updated, rather I'm hoping it dies silently and everyone slowly forgets it existed... it's not my best work :smile:
A bit long-winded, but does that answer your question?