Jump to content

Disconnected due to server errors - multiplayer game


simpleyuji
 Share

Recommended Posts

Im making a multiplayer game using phaser on client and node.js/socket.io on server and I'm currently not sure how to handle exceptions on server-side. Basically, whenever there are uncaught exceptions (perhaps due to some edgecase i didnt foresee), the server will crash, and the game state which gets stored in-memory for speed and updated every 33ms will get lost, including disconnecting all connected players  (ie. 20 players will get disconnected if there's an unexpected server bug). Even if there's automatic restart, it'll be a new process with new memory and new socket connections. 

 

So my question is, how do i auto-catch these exceptions, so that I can handle them via an email notifier instead, and let the game continue on smoothly (prevent client disconnect) ?
 

Link to comment
Share on other sites

I think that you should really put much effort in not having those exceptions in the first place. I know it sounds easy and dumb, but there's no real reason why you should be ok with having exceptions. Try to find repro-steps and fix the bug. Even if you managed to properly catch the exception, it might still have bad consequences on the game and thus on the players experience.

If you really don't mind having those errors, I don't see any magical solution. Try to put a try{}catch{} at the very root of your code (probably where the Phaser game is instantiated or something like that), and log/mail the exception instead of throwing it.

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...