Master servers, routers, firewalls and confusion
by Daniel Buckmaster · in General Discussion · 01/18/2010 (4:11 am) · 40 replies
I've just come to start testing my game over a network, and realised there's a lot I don't understand about how gaming works over a network.
Can anyone point me to some good guides on basic networking - ports, routers, firewalls, etc.?
And specifically - I've got a wireless router connected to my modem and desktop with cables. The laptop is connected to the wireless network. I can Host a game on either computer and access it via 'query LAN', but when I query the master server, I find nothing. On the connecting side, I get a console error about having the wrong protocol - but it does say one server was in the list (it just didn't show up in the GUI).
I really don't know if it's actually an issue with firewalls and such, or whether it's my code/script setup. But help in either area would be appreciated ;).
Can anyone point me to some good guides on basic networking - ports, routers, firewalls, etc.?
And specifically - I've got a wireless router connected to my modem and desktop with cables. The laptop is connected to the wireless network. I can Host a game on either computer and access it via 'query LAN', but when I query the master server, I find nothing. On the connecting side, I get a console error about having the wrong protocol - but it does say one server was in the list (it just didn't show up in the GUI).
I really don't know if it's actually an issue with firewalls and such, or whether it's my code/script setup. But help in either area would be appreciated ;).
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
01/18/2010 (5:44 am)
Quote:As far as i know, the router should forward the port to the host.See, that's why I need to spend a little more time understanding the basics of the internet and networking... I have no idea what that means ;P. But thanks for the pointer, I'll see what I can find.
#4
...regardless, I'm still pretty clueless :P. I understand the idea of an IP address, and I think I understand ports.
Client-side prefs:
I'm just testing on the one computer now, which might be messing things up a bit - but I thought it was possible to host a dedicated server and connect to it on one computer. So anyway, I host a dedicated server, and it seems to be all right, sending a heartbeat and receiving info requests. When I start up Torque and query the master, this is what I get:
Could it be because 28002 is already in use by the dedicated server? So can I not actually host a server and connect to it within my own network other than via LAN? Can others outside my network see and connect to it?
Bah :P.
01/18/2010 (7:50 am)
Thanks for those :). Wikipedia was no help for a beginner (as usual), but portforward.com was good - I'd encountered that before when I was searching around this topic, but didn't realise it had some pretty good guides and introductions....regardless, I'm still pretty clueless :P. I understand the idea of an IP address, and I think I understand ports.
Client-side prefs:
$pref::Master0 = "2:master.garagegames.com:28002"; $pref::Net::Port = 28000;Do they mean that I'm connecting from port 28000 of my router to port 28002 on the GG master server? If so, does that mean I need to forward external port 28002 and internal port 28000 to my computer's internal IP address?
I'm just testing on the one computer now, which might be messing things up a bit - but I thought it was possible to host a dedicated server and connect to it on one computer. So anyway, I host a dedicated server, and it seems to be all right, sending a heartbeat and receiving info requests. When I start up Torque and query the master, this is what I get:
Quote:So it seems like it knows my server is there... but what's this about 28003? It seems like that port would be blocked by my firewall... but why's it trying to connect to 28003 in the first place?
ServerQuery: start Querying master server 0
No master servers found in this region, trying IP:74.63.12.22:28002.
Requesting the server list from master server IP:74.63.12.22:28002 (2 tries left)...
Received server list packet 1 of 1 from the master server (1 servers).
Pinging Server IP:110.32.97.xxx:28003 (3)...
Pinging Server IP:110.32.97.xxx:28003 (2)...
Pinging Server IP:110.32.97.xxx:28003 (1)...
Pinging Server IP:110.32.97.xxx:28003 (0)...
Ping to server IP:110.32.97.xxx:28003 timed out.
ServerQuery: query Querying servers: 0 left... 0.5
Could it be because 28002 is already in use by the dedicated server? So can I not actually host a server and connect to it within my own network other than via LAN? Can others outside my network see and connect to it?
Bah :P.
#5
I use always port 28002.
Then inspect $pref::Net::DisplayOnMaster.
At home all three computers and my router are connected with a LAN-Switch. In the settings of my router i activated port-forwarding 28002 to one of the three computers. And this one computer can host a game. The other two are always the clients.
The startHeartbeat-Function is sending all values you specified in $Pref::server::... to the master server.
Should be possible.
Yes. They are "talking" only with your router.
01/18/2010 (8:21 am)
Quote:OK, the first you have to inspect is the function setNetPort(yourPort);
So it seems like it knows my server is there... but what's this about 28003? It seems like that port would be blocked by my firewall... but why's it trying to connect to 28003 in the first place?
I use always port 28002.
Then inspect $pref::Net::DisplayOnMaster.
At home all three computers and my router are connected with a LAN-Switch. In the settings of my router i activated port-forwarding 28002 to one of the three computers. And this one computer can host a game. The other two are always the clients.
The startHeartbeat-Function is sending all values you specified in $Pref::server::... to the master server.
Quote:
Could it be because 28002 is already in use by the dedicated server? So can I not actually host a server and connect to it within my own network other than via LAN?
Should be possible.
Quote:
Can others outside my network see and connect to it?
Yes. They are "talking" only with your router.
#6
- To play over the internet, startHeartbeat and stopHeartbeat are required (Masterserver).
- queryLanServers and queryMasterServer
Before queryMasterserver is execute setNetPort(28002); but before queryLanServers i execute setNetPort(0);
01/18/2010 (8:31 am)
The differences between LAN and Internet are not so big. The workflow in Torque is always the same except some tiny things. - To play over the internet, startHeartbeat and stopHeartbeat are required (Masterserver).
- queryLanServers and queryMasterServer
Before queryMasterserver is execute setNetPort(28002); but before queryLanServers i execute setNetPort(0);
#7
...so I did, and I get the same console stuff as above - but it's port 28004 this time.
I guess my main concern here isn't for me - it's for the people who'll want to play my game. I want to be able to tell them exactly what hoops to jump through to get themselves playing online! I really wasn't aware of all this port forwarding and stuff until I started messing with Torque... other online games I've played I didn't have to do anything of the sort to get online.
I guess what I need is to be able to test actually over the internet, with someone on a different network. Cue sending my build to a friend...
01/18/2010 (8:59 am)
Quote:OK, the first you have to inspect is the function setNetPort(yourPort);I haven't changed stock TGE scripts, at least where networking is concerned. (EDIT: And I just tried with a clean TGE install, I get the same behaviour - can't connect via the master, but can via LAN.) setNetPort is called from portInit($pref::Server::Port), which is called when a server is created. And $pref::Server::Port is 28000. So maybe I should change that?
I use always port 28002.
...so I did, and I get the same console stuff as above - but it's port 28004 this time.
Quote:Then inspect $pref::Net::DisplayOnMaster.Good idea ;P. But I did a search, and this variable isn't found anywhere in my code base, except somewhere in the common net scripts, where we test to see if it's equal to "Never". So unless it defaults to that, I'm OK. (After thinking about that: I searched through the engine code, and no mention of it - so it should default to "".)
Quote:In the settings of my router i activated port-forwarding 28002 to one of the three computers.When I went to port-forwarding settings, it asked for an external port, internal port, and IP address. I assume the external port is 28002 and internal port is 28000? To match the $pref variables? And I forward them to my desktop's internal IP address? (Which as far as I can tell is static.)
Quote:Yes. They are "talking" only with your router.Yep - but for some reason I can't talk to my own router successfully.
Quote:Before queryMasterserver is execute setNetPort(28002); but before queryLanServers i execute setNetPort(0);I tried that in the console - no dice. I get the same console stuff I quoted above, but again with the 28004 port.
I guess my main concern here isn't for me - it's for the people who'll want to play my game. I want to be able to tell them exactly what hoops to jump through to get themselves playing online! I really wasn't aware of all this port forwarding and stuff until I started messing with Torque... other online games I've played I didn't have to do anything of the sort to get online.
I guess what I need is to be able to test actually over the internet, with someone on a different network. Cue sending my build to a friend...
#8
The following assumes you have one TGE game server running on one pc at local ip address 192.168.1.254.
01/18/2010 (8:04 pm)
Something like the following port forwarding rule in your router plus an exception in Windows Firewall, or whatever firewall is running inside your pc, should be all you need in the example given above.The following assumes you have one TGE game server running on one pc at local ip address 192.168.1.254.
# Server Name Start Port End Port Server IP Address 1 My TGE Game 28000 28000 192.168.1.254
#9
EDIT: No dice. LAN is fine, but when I query the master, I don't find any servers at all. And I did make sure to change the local IP address to my desktop's address ;P.
01/18/2010 (9:13 pm)
Instead of 'start port' and 'end port', my router has 'external port' and 'internal port' options. I'm guessing that's not an issue, since they're the same? I'll have a go... thanks.EDIT: No dice. LAN is fine, but when I query the master, I don't find any servers at all. And I did make sure to change the local IP address to my desktop's address ;P.
#10
What I do is connect directly to my server through the internet by using dynamic DNS like www.DynDns.org, which allows you to sync your PC's at home with a free subdomain like yourdomain.dyndns.org. Worked great for a recent demo I hosted of my game.
Edit: Your wireless router should have a feature to sync up with DynDns.org. Many do.
01/19/2010 (1:03 am)
The external and internal ports should be the same (set your hosting PC up to have a static IP, or else you'll be changing that forwarding setting just when you don't have the patience to), and you should forward the range of 28000 to 28004 and you should be able to connect. That said, I never use the master server...What I do is connect directly to my server through the internet by using dynamic DNS like www.DynDns.org, which allows you to sync your PC's at home with a free subdomain like yourdomain.dyndns.org. Worked great for a recent demo I hosted of my game.
Edit: Your wireless router should have a feature to sync up with DynDns.org. Many do.
#11
If I do it without the single port forward enabled, I find no servers at all.
01/19/2010 (1:44 am)
So I set up a single port forward from port 28000 to my computer's static internal IP address (192.168.1.100), and port range forwarding 28000 to 28004 to the same IP address (both for UDP and TCP). Now I get the same console timeout log as above, but with port 28005.If I do it without the single port forward enabled, I find no servers at all.
Quote:Your wireless router should have a feature to sync up with DynDns.org. Many do.Mine does (requires a dyndns.com account, obviously). So doing that will allow me to use my computer as a master server of sorts?
#12
- If it works fine, it has something to do with your hardware.
- Otherwise you have a bug.
01/19/2010 (3:54 am)
Daniel, can you send me your project? I would try it at home. - If it works fine, it has something to do with your hardware.
- Otherwise you have a bug.
#13
01/19/2010 (4:47 am)
I've been using stock TGE1.5.2 most recently, so I assume it's my hardware. (And my own project hasn't really changed much in the realm of network scripts.) I think I'm just doing it wrong, which wouldn't surprise me.
#14
01/19/2010 (5:45 am)
If you use the original starter.fps, do you get the list of the master server?
#15
On a fresh install, I just start torqueDemo.exe and go straight to join game -> query master. In the console, it says there was one server in the list, but I times out when trying to contact it.
When I host a dedicated server on my computer, and then run torqueDemo.exe and query the master again, I get exactly the same result. So it seems my hosted dedicated server is not showing up on the master - though in the console for the dedicated server I see it sending heartbeats and getting info requests.
01/19/2010 (7:24 am)
Nope.On a fresh install, I just start torqueDemo.exe and go straight to join game -> query master. In the console, it says there was one server in the list, but I times out when trying to contact it.
When I host a dedicated server on my computer, and then run torqueDemo.exe and query the master again, I get exactly the same result. So it seems my hosted dedicated server is not showing up on the master - though in the console for the dedicated server I see it sending heartbeats and getting info requests.
#16
I'm just writing a master server for Linux and I wanted to test it with stock TGE anyway (I'm currently using a modified TGEA version for testing). Maybe I can run these TGE test tonight and see if and what's wrong there...
01/19/2010 (7:57 am)
IIRC there was exactly this problem you have with stock TGE. If you set $Client::GameTypeQuery and $Client::MissionTypeQuery to "Any", you should be able to see all servers on the master (including yours). If you can see your own server with these settings, there should be something wrong with the GameType / MissionType settings.I'm just writing a master server for Linux and I wanted to test it with stock TGE anyway (I'm currently using a modified TGEA version for testing). Maybe I can run these TGE test tonight and see if and what's wrong there...
#17
01/19/2010 (8:01 am)
Check your virus scanner. See post #1.
#18
Port 28002 is used.
www.darkware.de/TGE_from_Scratch.zip
01/19/2010 (8:30 am)
Daniel, this is a very early test to make a project from scratch including multiplayer. The game works very well over LAN and Internet. Port 28002 is used.
www.darkware.de/TGE_from_Scratch.zip
#19
01/19/2010 (8:33 am)
Thanks - I'll give it a go, but I don't expect it to work. I'm still not understanding the interactions between Torque, the GG master server, my router, port forwarding, etc. Add that to the fact that my net connection isn't brilliant and I'm really not sure where the problem lies ;P.
Torque 3D Owner Thomas Bang
Another reason could be port-forwarding. As far as i know, the router should forward the port to the host.