I own a semi-popular typing game that gets a quite a bit of traffic, especially since it’s Multiplayer.
We almost exclusively rely on Socket-io, and since joining Cloudflare we have had several problems for at least 5-10% of our users.
Nginx, Express, Socket-io
When playing in a match specifically (since that’s the easiest to note) the user would randomly get disconnected and the match would not finish because of course it was disconnected. While we could introduce a build-in reconnection logic, it would still revolve around creating several edge cases that would help only short term.
When a player disconnects, Socket-io registers it as a “transport close” and even Socket.io’s logging doesn’t specify any errors. However most of the time it will just reconnect instantly and act as if nothing went wrong.
Over the past bit, we’ve tested created different servers and hosting the same game and trying different configuration and this is what we’ve pretty much discovered.
All of these tests were conducted doing 20 matches on each.
- Socket-io with SSL and Nginx - working
- Socket-io with Nginx - working
- Socket-io with Cloudflare, Nginx and SSL- doesn’t work
- Socket-io with Cloudflare and Nginx - doesn’t work
Now over the periods of time we’ve tried ignoring this issue, but of course with a growing player base the problem has arose several times over the course of just a couple months so we are trying to find an actual solution.
The reason why we do not open the Socket-io portion outside of Cloudflare is due to DDoS. It’s a common problem in every gaming community so it’s very hard to allow that exposure to our servers at the moment.
We’ve also tried modifying the pings, making sure it isn’t a problem with Cloudflare automatically disconnecting after X amount of time. We’ve also reflected this change in Nginx to also make sure. We have also used
trust proxy in Express, we’ve pretty much tried everything at this point.