Making multiplayer reliable: reconnects and dropped connections
Mobile networks drop out. People switch from Wi-Fi to data, lock their phone mid-game and walk into lifts. A multiplayer game that cannot cope with that is not much fun. Here is how Atom Reaction deals with it.
The problem
In the first version, if your connection blinked, the game showed a frozen board and you had to reload. Reloading often lost your seat, and the bot took over your turns almost immediately, so you came back to a game that had moved on.
Automatic reconnect
The game now reconnects by itself. After a drop it retries with a growing delay, starting at half a second and increasing up to eight seconds. It also retries immediately when the page becomes visible again, when the network comes back or when you return to the tab. A small "Reconnecting" pill shows at the bottom so you know what is happening.
Detecting a dead connection
Some connections die silently, so neither side notices. The client sends a small ping every fifteen seconds, and if nothing is heard for twenty five seconds it closes the socket and reconnects. In the worst case a silent failure is noticed in about forty seconds.
Keeping your seat
Seat credentials used to live only in the tab. Now they are stored in the browser so that opening the invite link again, even in a new tab, gives you the same seat back instead of a new one.
A fair grace period
When a player goes offline, the server now waits fifteen seconds before a bot plays their turn. It used to be just over a second, which was far too aggressive. The grace period covers a quick reconnect without making the other players wait for long.
How I tested it
I tested reconnects with a real server and a small proxy placed in front of it. The proxy could reset connections, refuse them, or silently swallow traffic, which are three different failure modes that behave differently in browsers. Testing only the polite case, where the connection closes cleanly, would have missed the silent failure completely.
More Atom Reaction guides
- How to play: The complete rules, critical mass numbers and a worked example of a chain reaction.
- Strategy guide: Ten practical tips for the opening, middle game, endgame and Battle Royale.
- Game modes: Online rooms, bots, pass and play, daily puzzle and Battle Royale explained.
- FAQ: Quick answers about players, bots, accounts and installing the game.
- Opening moves: Where to place your first orbs and what to avoid in the first five turns.
- Corner strategy in Atom Reaction: Why corners are the strongest cells and how to build chains out of them.
- Common Atom Reaction mistakes: Seven mistakes that cost new players games, with a fix for each.
- Beating the Atom Reaction bots: How each bot level thinks and the habits that beat them.
- Multiplayer tactics for Atom Reaction: Target selection, kingmaking and surviving a crowded board.
- Battle Royale survival guide: How the shrinking board works and how to be the last one standing.
- Two player strategy for Atom Reaction: Tempo, forcing exchanges and corner control in head-to-head games.
- Reading the board in Atom Reaction: A simple scan routine to spot threats and chains before they happen.
- Trap patterns in Atom Reaction: The decoy corner, the delayed fuse and the forced capture.
- Endgame guide: Count orbs, keep reserve moves and finish the last opponent.
- Choosing the right board size: How the grid size changes pace, tactics and player count.
- Reviewing your games to improve: Using replay and post-game review to find the move that lost the game.
- Hosting a game night: Rooms, invite links, spectators, chat and keeping everyone engaged.
- Playing on your phone: Install it, switch on lite mode and get turn alerts on any phone.
- How the Atom Reaction backend was built: FastAPI, WebSockets, in-memory rooms and a chain-resolving game engine.
- Backend challenges we faced and how we fixed them: Endless chains, room floods, rate limits and server hardening.
- Frontend challenge: why phones got hot and how we fixed it: Cached sprites, frame pacing and lite mode to cool down phones.
- How the Atom Reaction bots were built: Alpha-beta search, web workers and the experiments that surprised us.
- Saving games to a database without slowing play: A sleeping PostgreSQL database, background queues and privacy purges.