2
votes

I am currently developing an android multiplayer game (one on one fighting) using libgdx graphics api and the kryonet api for all server client networking . In case you might not know , libgdx is an open source java api for game development . Kryonet is an independent networking api suitable for games pc,android and linux . So far everything is going good ,... made a server , 2 clients as players .

I tried running server and clients in pc . Its working . I then tried running server on pc and player clients in android phone . Its working .

But... the problem happend when i use my android phone as a server . my client program cannot discover the android server . I even made sure i used the ip of my phone from whatsmyip.com . But my android server is still invisible . I made sure i set the manifests correctly with the internet permissions .

Is it even possible to run an android phone as a server due to its mobild ip ? I badly need to make this work so that a central server is not needed . Players can simply play in a p2p fashion where one players starts a server and the other player just joins the server player .

1

1 Answers

1
votes

I've had a similar problem. I'm assuming your trying to use the mobile network connection. The issues is that your mobile is probably behind a set of firewalls. I've looked at different solutions that can be used to overcome the problem.

The issue is that the ip address you see external as your phones IP address is not a "real" address. This is a gateway that many mobile devices are going out through. The gateway uses a technique called NAT tables to decide what traffic that comes to this IP address belongs to your device. Any traffic that the gateway receives that it does not expect it generally ignores. This article gives a good overview of the issues.

There are ways around this have a look at different hole punching methods (STUN...).

I tried several different ways to get around this, but In the end I had to look at using a relay server. I used a Amazon Web Service (AWS) who provide a free tier which is fine to get your app up and going. It would be good to get you started, I've been using that for my relay of messages.

Hope this helps.