• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Server crashing

Darkgot

Member
Hi, I have a server running that accept TCP connections for my game. I have connections that are not coming from my game and they are generating errors that crash my server. even if after the connection I request a password or a confirmation key or what ever if it's not coming from my game the answer will be the wrong format and will result in an error generated by the server and the server will crash.

How do you fix that? is there a way to bypass the first format error so by that being abbe to put the socket of that connection into a black list to avoid communicating with it?
 

Mr Magnus

Viking King
A ) Whatever language you're using will have try/catch blocks. Use those to catch exceptions thrown by your server, deal with them gracefully, log them in case these are actual issues you need to fix, and drop the connection or respond as appropriate. No matter the issue your server should always be able to catch any exception and recover without crashing.

B ) Verify the format of your incoming message. Do not assume that all messages you will get are of the right format. When you get a packet examine if it's in the right format, it has the required information, and it's up to code. If it is proceed. If it is not discard it and return a bad request response.

C ) Try detecting requests that aren't from your game. Have a custom header, an API key, a fixed format you can check against no matter the message, whatever. Drop connections that don't supply the right information. This won't filter out maliciously crafted forgeries, but accidental connections that simply don't know better can be dropped.
 
Top