Sign in to follow this  
simpleyuji

Disconnected due to server errors - multiplayer game

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) ?
 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.