Game Development Community

server connection problems

by Robert Fritzen · in Torque 3D Professional · 07/21/2012 (2:33 pm) · 14 replies

Hello everyone, so today I had a test run with my other developers for my project, however we are experiencing an issue with the network.

First off, we cannot see eachother's servers in the master server list (I'm using a PHP script to list the IP'sof the servers and then querySingleServer to try to connect to it).

This always times out. So we then move to connect("IP");, and this also times out.

Firewalls are open, but I have no idea how to implement a way to test this to ensure they are open and allowing connections through.

Any ideas on how to fix this?

#1
07/22/2012 (12:26 am)
Are you storing the data in a database? I have found with some mysql dbs that I have to do an explicit start transaction and commit transaction to get it to update the db.

Also, do you have another program you can use that talks to your server? Something you know works and can use to debug. I often write small programs in Python for this purpose. You may also try using something like Putty or some similar network client to debug the connection.
#2
07/22/2012 (8:32 am)
My setup works a bit like this:

1) Served starts, and calls startHeartbeat(); I have this function modified to send up a request for server addition to the list, it sends the port the server is using up.

2) PHP gets this request, and saves the IP and port of the requesting server in the list, as well as a 3 minute time ticket for when the server is no longer on the list.

3) at random intervals between 2 and 3 minutes the server calls startHeartbeat() again, sending the same port info up.

4) PHP sees the same IP in the list and just updates the time ticket to 3 minutes after the request was received.

For Query, PHP sends a list of IP:Port down to the requesting client, and then the client simply calls querySingleServer() on that server.

My problem is, although my server appears in the list on the SQL, and I can get this information by using the query, nobody else can do this and connect to the server, they only time out when trying to connect.
#3
07/22/2012 (1:02 pm)
Where are the server, the webserver, and the other servers? How are these physically connected?
#4
07/22/2012 (1:31 pm)
Have u tried to ping your game server ip from a external machine?
#5
07/28/2012 (10:14 am)
Sorry for the long reply, I still play Tribes 2 (it uses the same network port as my project), and it receives connections just fine, so I'm pretty sure that eliminates the port problem, unless if setNetPort is failing miserably (which unless the console echo is lying, it is not), or there is something else going on here.

As for pinging the server, I'll give this a test later, but I'm still going to directly assume that since this works on the older version of Torque (Tribes 2), that this is a problem with something else.

*EDIT*
I want to shoot myself now, lol.... my list function was calling $con1 instead of $con in PHP for MySQL, I'll need to see if the server list properly displays now, but the timeout problem still exists.
#6
07/31/2012 (3:11 pm)
Ok update here. My friend tried to ping the server and it failed to reach it.
#7
08/01/2012 (7:11 am)
So this is a port forwarding issue, which shocks me, because I would think that T3D would support the UPnP protocol on most routers.

Can we get this added in? Seems like a very important feature that is missing on the network side of T3D...

*EDIT*
Found this: http://www.codeproject.com/Articles/27237/Easy-Port-Forwarding-and-Managing-Router-with-UPnP

would this work?
#8
08/01/2012 (8:35 am)
So, you've multiple computers behind your router? I'm going make some assumptions here... you have NAT addresses on your side, you have different computers for your master server, your game server, and your database server. This is how I got everything to work inside my network, which is behind a very standard consumer router on a static IP.

I am guessing you have not set up port forwarding for incoming traffic, so queries are not being sent past your router and directed to the correct machines.

Inside the router's configuration, look for "Port Forwarding" and make sure you are forwarding incoming traffic arriving on port 28002 to the internal IP address of your master server computer. This is the port the master server is listening on, but your router may not be set up to send that traffic on to the correct internal address.

Then you need a forwarding line for traffic arriving at your game server, which is probably on 28000.

Traffic intended for the MySQL server should explicitly direct traffic on port 3306 to the internal IP address of that machine.

So rules look vaguely like:

28002 -> 192.1.1.10 (Master server machine)
28000 -> 192.1.1.11 (Game server machine)
3306 -> 192.1.1.12 (MySQL machine)

Also, clients outside your LAN will need the IP address of the router (the gateway) to find it. This is easy if you have a static IP, less so if it is dynamic. (If you have an IP which changes all the time, look into dyndns.org and similar services for a way around that issue.) Clients inside your LAN can use the external address or the internal NAT address.

This is not 192.1.1.1 (or whatever) which is what you see from inside your network as your gateway, but the external address assigned by your provider. It is usually visible in the router's conf pages, or may be in your documentation.

Then traffic coming from the outside world on those ports it will be sent to the right machine to handle it. If all your servers are on the same machine, you might have a different issue, but I'd still try explicitly specifying the port mapping.

Again, this is how I got multiple servers working, YMMV but good luck!
#9
08/01/2012 (8:46 am)
This is what's confusing, my computer was properly configured (28000) for the game server, but it was invisible and would then timeout other people who tried to join it.

The master server is actually outside of my network, being ran on my web server, so that's fine. the SQL server is attached to the web server, so same place as the master.

The only problem here is on the local end, and unless I'm misunderstanding here, T3D is not equipped with functioning to invoke UPnP on routers (Which is almost standard on all game engines anymore). This would address that issue. (I think attaching it to the setNetPort Function could handle this)

I'm just wondering if anyone has tried this and has had success.
#10
08/01/2012 (8:54 am)
Torque does not have any UPnP support at all as UPnP is not available or disabled on majority of firewalls and NAT routers out there that are deployed or maintained by anybody that has a clue about network security. After all, what is the point of having a firewall when a machine within the LAN can just arbitrarily decide it wants a port opened for a direct connection coming from outside the firewall in on the fly? Port forwarding via UPnP is a security nightmare and just helps malware/viruses spread a lot easier when incoming port forwards can be opened up on the fly like that: for example your machine gets infected via vulnerable Flash or Java runtime flaw and it figures out it can open port forwards to its self for outside connections coming in so now it serves as a command and control relay host.

That's enough of that security ranting. All you have to do is go port forward UDP/IP 28000 (TGE/TGEA/T3D port default) in your NAT router to your machine that is running the Torque server. Now your friend should be able to join your server by using connect("<YourHost>:28000"); command in the console to immediately try connecting to your server. <YourHost> can be either just your public IP address or a FQDN that resolves to your public IP address.

Your server should now also be appearing within the server browser (to everybody outside of your LAN) as the game client's server browser will only list servers that it receives query responses from which uses the same data exchange communication method as if it were trying to join the game server.

About your friend unable to ping your machine. That is all controlled by firewall rules dealing with ICMP. If you have ICMP filtering turned on or explicitly dropping/filtering ICMP type 8/echo-request then nobody would receive a ping response from your public IP address. Which isn't directly related to port forwarding as machines behind NAT router are not pingable from outside the LAN to begin with.
#11
08/01/2012 (9:06 am)
Thanks for the reply regarding this. I guess avoiding UPnP is probably a good idea then.

But, I said before the server was already properly port forwarded to 28000 UDP, the port has not changed from 28000 either.

I triple checked it after connections failed multiple times with no success. IS there any way to easily and securely implement a port check on T3D to see if the port the server is using is properly open and if not to flag a warning message out to the dedicated console screen that it is not?

It would help to crack down on this problem a little more if that was present.
#12
08/01/2012 (9:19 am)
Try using cports from Nirsoft.

It will let you see open ports. You have to refresh it to update to see the recent ports associated with which programs. There are probably command line utils, but this is pretty simple and easy.
#13
08/01/2012 (10:02 am)
@Robert: But have you made sure that the port forward entry is set to forward to the correct machine on the LAN though? Such as does your machine have a static LAN IP that the port forward is configured to forward to or does your machine change IPs because the NAT router was restarted (such as power loss) and losing its DHCPd state?

For me because I use a dedicated machine running Debian Linux distribution as the primary LAN server that serves for NAT routing (iptables ftw) and DHCPD that I configured myself so that the DHCPD always hands out the same IP address to all my machines based off of the NIC MAC address (DHCP served static IP addresses). I can just set the port forwards once and be done with it until I switch physical machines or replace a NIC. Alternatively you can configure your machine to a static IP address and bypass DHCP completely, although be careful that you write down and reuse your DNS settings first and that you reconfigure your NAT router's DHCP server to not hand out addresses in the range that you're statically assigning IP address(es) to your machine(s) to prevent possible IP address fighting which is rare with badly programmed DHCP servers, if you're going to go that route that is.

As for the Torque server detecting whether or not it has a working public reachable port that would require it to communicate with a special outside server that would attempt to use, and test via data exchanges, the specified port coming from either a different IP or an unused source port to prevent the existing UDP NAT routing session from giving a false positive. This could even be implemented as a master server protocol extension, plenty of unused tokens.
#14
08/01/2012 (10:04 am)
Yes, my IPs on the local NAT are static, so no issue there. It is forwarded to my local machine. I tried to use both a listen and dedicated server both without success.

Would my web server work for that? Can this be written in PHP and then communicate with TS via TCPObject?