🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to get my networked game online?

Started by
6 comments, last by hplus0603 3 years, 2 months ago

Hi,

I've been working on a networked multiplayer game. I am an experienced game engine programmer, but haven't done much network programming since the mid-2000s. I've been testing my game locally using localhost and everything works fine. Today I tried to do an online test and was unable to figure out how to allow others to connect to my PC. I added port exceptions to Windows firewall and my router, but online tests say that the port is blocked. At this point I've come to the conclusion that in the interests of security my ISP is blocking incoming connections.

My next though was to use an online service like Amazon Web Services or Microsoft Azure. I spent the entire evening perplexed by their websites. They want you to use their services with invasive APIs that require lots of third-party code and JSON parsing and all kinds of weird stuff. I just want a server where I can dump my executable, run it, and have clients open sockets to connect to it. Seems like it shouldn't be difficult.

Any suggestions?

Thanks,
Aaron

Advertisement

You have to add port forwarding to your router or else it won't know which IP is the recipient of connection requests from the internet. A possible cause of this not working is if your provider runs IP clustering. This means you and a couple of other people are using the same public IP address and your provider manages connections using different port ranges.

You should first check if your provider uses IPv4 or v6 public addresses and if IP clustering is enabled (you can do so by requesting new IPs in your router and see if it changes). However, your game should be able to treat IPv6 as same as v4 connections, you may need to turn off IPv6 in your Windows machine as well if you have connection issues.

There are also services like Hamachi, which allow to treat internet clients as if they were in your local network. If port forwarding doesn't work, try this first.

To host your game on an internet server you have a set of options. Using a virtual server is the cheapest way of getting your game running, however, you should be able tu host the game as a service (Windows) or deamon (Linux) or else you'll have to start it again periodically as your “user” will be logged off after some time. Amazon Cloud Services is ok for getting a VServer, be aware that Windows machines are more expensive and you pay per CPU-Core + RAM + Storage.

The second option is to get a dedicated hosted server which is more expensive than a virtual one

Thanks for the response. I did set up port forwarding on my router but the online tests say the port is blocked.

My ISP FAQ says “Due to the shortage of IPv4 addresses, we use Carrier Grade Nat (CGN) which allows for more efficient use of our IPv4 address range. This means that each time you access an IPv4 website, our network seamlessly allocates you a dynamic, rather than static, IP address from our pool of public addresses, with no disruption to service. ”

Apparently I can pay extra to get a static IP address. Would that help? I also have a static IPv6 address, but if I use that then I assume that many people would not be able to connect.

Thanks,
Aaron

AaronKM said:
Apparently I can pay extra to get a static IP address

Yeah, your provider seems to use IP clusters as you describe it above. This is always tricky and made me some headaches for our online service.

AaronKM said:
I also have a static IPv6 address

Then don't spend money for a static IPv4 one, it is uneccessary! IPv6 is mostly supported now and your game should support it as well. To do this, you can (if not already done) disable the IPV6_V6ONLY socket option when establishing a connection so a socket will be able to handle both.

Also, don't trust port tests as you don't know which method they're using to test for open ports. Get someone from outside your local network to test if they're able to connect to your IP

[quote]I can pay extra to get a static IP address. Would that help?[/quote]

Yes, that would help.

[quote]IPv6 is mostly supported now[/quote]

This varies wildly by location in the world, by ISP, and by location. I'm sure that, at some point, “just use IPv6” will be the right solution, with no customer support problems, but that time is not yet.

enum Bool { True, False, FileNotFound };

I actually decided that my idea wasn't going to scale anyway. I was hoping a test server would be easier, but oh well. After some research I've decided to go with Epic Online Services to handle all the peer to peer NAT stuff and matchmaking for free. It will be much cheaper this way. The library seems good as well. Unfortunately I have to rewrite all my networking code.

Anybody tried it out yet? So far I can connect to the server and authenticate the users. Next step is to add session code.

Thanks,
Aaron

Well, one game that has “tried” Epic Online Services is Fortnite, so … I think it works alright? :-D

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement