[ANet or other maybe] Auto-remove dead servers from serverlist

Posted By: Razoron

[ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 14:00

Hi,
the serverlist is stored in a MySQL database on a debian root server.
Everyone can host games. But what, when the internet connection of the hosting gamer is interrupted?
The server is still in the serverlist, but in reality it doesn't exist anymore.
How to remove the "server corpses"?

- Let the server do "cronjobs" every minute to check if he can connect to the server.

But how to do that? I could code a program using winsock, that runs on the server. The problem: How to connect to an ANet game server without calling the EVENT_CONNECT events.

Any suggestions how to do this and cleanup the serverlist?
Posted By: Germanunkol

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 14:20

We send updates. If a server on the list isn't updated after waiting for 60 seconds, then that means the server is not running any more.

Then (if I remember correctly) every time someone attempts to download the list of servers, we run a code to check which server entries in the list have not been updated during the past 60 seconds, and those are deleted before returning the server list to the one who requested it.

May not be the best method, but it works great for us.
Posted By: Razoron

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 14:26

Yes, thats a solution without an external cleaner program. It is not the fastest, but possible. Thanks laugh.
Other suggestions are still welcome.
Posted By: SchokoKeks

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 16:54

I've once used the same method as Germanunkol, it worked ok.

problem was that the few servers made by players were usually unconnectable because the users didn't forward the ports the server needed. They didn't know their servers were unconnectable and they stayed in the list because regular updates were send.

Others players quickly got frustrated when they couldn't connect to any game.

A much cleaner solution would be server-side checking for the "connectablility" of the servers. You could try to connect via raw UDP with ANET and PHP (if UDP is allowed on your server), or you'd have to use an external program.
Posted By: Razoron

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 17:48

You can open an UDP socket with PHP?
Great, I will check it out.
We have root access to our, server I think this won't be the problem.
Posted By: WretchedSid

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 18:35

Why not use NAT-PMP and/or UPnP to open the ports? The players want to play the game, not play with their routers. (I know that this is Off-Topic)
Posted By: Razoron

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/10/10 20:40

That's a point we can think about if the game is ready.
There is also Warcraft III, a very popular game, where the host has to open the port manually, but it is still very succesfull. I hope, that won't be the problem.
Posted By: Dark_samurai

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 09/18/10 16:08

Quote:
Then (if I remember correctly) every time someone attempts to download the list of servers, we run a code to check which server entries in the list have not been updated during the past 60 seconds, and those are deleted before returning the server list to the one who requested it.


The serverlist template of ANet does it exactly this way. This method is great because it can be done in PHP+SQL without a special program or setting on the server.

Quote:
A much cleaner solution would be server-side checking for the "connectablility" of the servers.


You could also implement the first methode and let the client (the one who is searching) check if he can connect to the servers in the list. This way you can also get informations about the ping to the server.
Posted By: darkinferno

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 10/20/10 15:49

how would you accomplish that check? i mean, not like you can make him join all the servers and disconnect.. [srry, not a pro at mp just yet]
Posted By: Dark_samurai

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 10/20/10 16:36

You could do it with sockets. Every server has an opened udp socket and the client tries to send a packet to them and waits for an acknowledge packet. ANet although only supports one udp socket opened at the same time so this would be slow. But if you access the windows socket functions from Lite-C you could open more sockets at the same time => faster
But I never tested this, so it's possible that this idea won't work good/fast enough.

Checking it through a timestamp in the sql db is also no bad methode at all. So the decision is yours if you think it's worth to try the socket based methode. I never did...
Posted By: nfs42

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 10/20/10 22:12

GSTChannels uses php/mysql on a http-server to register servers.
every 60 secs the different 3dgs gstnet servers execute a non-blocking http request to update various properties for the appropriate server in the list with a timestamp.

the serverlist call is also an http request which execute at first a query to delete those servers where the last timestamp is older than 120 seconds (gui or non gui version).

that should work for most mp games.
Posted By: JibbSmart

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 12/03/10 15:14

Hey guys,

I've got a similar set-up for my serverlist (PHP and MySQL). I want to prevent servers behind routers that haven't set up port-forwarding from being able to create an online server, but I don't actually know anything about socket programming (neither A8 socket programming nor what to do on the PHP side).

Can anyone give me some hints? I can normally get through things by some trial and error, but this time I'm trying to solve 3 problems, and I won't know if any of them work until they all work:
1. Being able to receive information on A8's side;
2. Being able to send information from the PHP serverlist;
3. Port-forwarding on my own machine -- I'm behind a router, and while I think I've set it up I don't have a way of testing that it works :S

Thanks,

Jibb
Posted By: Dark_samurai

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 12/04/10 09:00

You could do this without writing your own socket program. You could let the game server open a "test server" before the real game server is started. Then this server sends a http_post() for calling a php script on the php/mysql server. This script starts a client.exe that tries to connect with the "test server" (so you should send the port of the game server to the script; you can get the ip address through a php instruction). If the connection is successful, the client.exe calls a php script on the localhost (because the php server and the client.exe run on the same machine) and this script adds the server to the list. If the connection event is called on your game server it knows that the client could successfully connect. => the "test server" is closed and the real server is started.

Shouldn't be to hard to implement with ANet. Just a few lines of code wink Also the php part is easy.
Posted By: JibbSmart

Re: [ANet or other maybe] Auto-remove dead servers from serverlist - 12/04/10 17:18

Thanks, I like the idea, but I'm using a free (for now) PHP/MySQL host, and while relatively soon I'm going to use a paid host, I'm still aiming for something really cheap (and thus it's really just PHP/MySQL). I'm not actually hosting the server myself, so I don't think I have enough freedom with it to run executables on the serverlist server.

Any code snippets or small examples from anyone for having A8 communicate with a PHP server through socket_connect?

I really have no idea.

Jibb
© 2024 lite-C Forums