For my game (based on JME2 and JGN for networking) I want to offer online support for games. I already have Server and Client functionality for a LAN, which is straight forward with the routing because it’s all in the same network and address space.
The problem for me is: how do I connect to a pc over the internet, when this pc is behind a router? I tried this once, but I wasn’t able to establish any connection. Is this even possible with JGN (or Java in general)?
My game offers a server broweser similiar to other existing multiplayer online games. As their server are all real servers that have to be paid, I wanted to try to put a master server (simple free webspace with PHP and mySQL) and store information about running games their. If a client wants to get the server list, it just asks this master server for it and returns a set of IP addresses. These IP addresses are addresses in the internet of course. But how do I know which PC is behind this if it is behind some router in a LAN?
I hope you understand my problem, it’s not easy to explain this… ^^"
- The user opens a port that will forward from their router to their computer. However this requires user to be “intelligent” or know about networks.
Ya. What Tralala said is the easiest way.
This is why games like WoW and what not have a central server you connect to that is available (through routing or whatever) on the internet publicly. At that point it’s a mater of the client connecting so that a route is established through the router and using that single connection for all traffic for the game. So if all game traffic goes through 1 public server then you should be fine. But if it’s setup that every user has their own server that people can connect to… well… then hopefully your user base knows about routes etc.
Looks like I’ll have to get “intelligent” users
In the end is it just something I want to offer. It’s not like the whole game stands and falls with online functionality, but it’s a nice feature though
At least it’s possible at all
I can’t think of a single game I’ve ever played that allowed me to host my own servers that didn’t have a FAQ page telling users which ports to map through on their routers.
…just a necessary evil.
Or you can use UPnP/STUN/TURN … Much less fun but doesn’t require port forwarding. This is how P2P tools like skype and teamviewer work
Do I understand it correctly that UPnP/STUN/TURN etc. require a (internet) Server running them? So this will not be the way because I’ll have to get (-> pay for) such a server, and thats not gonna happen
I just tried port forwarding at my router, and it surprisingly works just fine :o It even works at the same freaking PC, crazy how this just works out of the box So the next release of Infinite Wars will contain some Port forwarding information g.
I am thinking maybe we can add these features to OGF (Open Game Finder). Then the whole port forwarding mess is automatically taken care of for you. What do you think?
it would be cool
What features do you exactly mean? Obviously you cannot make routers forward ports, so you mean stuff like STUN? But this still doesn’t solve the problem with “I need a server on the internet, running 24/7 that I have to pay for”
The thing is that I already have a networking architecture using JGN and I’m not willing to completely throw this away. But thats just my standpoint.
Of course it will help other developers so go ahead and get this done, but for me it’s kinda too late g.
Just looking around and I found this article that kinda sums up how P2P applications and things that use similar protocols solve this. Basically you have a central server that stores all sorts of data, then through some pretty neat UDP manipulation you can forward data properly. http://alumnus.caltech.edu/~dank/peer-nat.html
So ya. It’s dooable. It just may be more work than you really want to do. It’s the difference between writing or adapting and existing protocol or writing a 1 liner in your help page that says “Port forward this port to your computer”.
And it comes down to whether you want to have a game that users can run servers on their own without your involvement or if you want to setup a potentially expensive public server to let them do that.
Running private game servers on the internet I thought was a pretty well understood problem for the kinds of players that like to do that sort of thing. Without having to route through a publicly run service.
…though if something like OGF is a game matching service then it should look at providing this coordination. That’s a different issue completely.
@thecyberbob Interesting article, but I’m still gonna go with the simple port forwarding because it’s still just my hobby
yaaaa. That’d be my suggestion as well.