Android - Java TCP Connection NAT Bypass

I am trying to configure a client / server model with android clients and a Java server. The connection is through TCP.

I have all my code working when the Android device is running in WIFI, however whenever I connect to a wireless network (e.g. 3g, 4g), the sockets refuse to connect.

I read about NAT traversal, but I don’t know where to start when you follow the necessary steps to allow the connection.

NOTE: my server has a static IP address

+4
source share
1 answer

I assume you have a network problem. Assuming your server is behind a router, your server socket should connect to its LAN IP address (not directly binding the public Internet IP address). Then you need to set up port forwarding, firewall rules, etc., so that anyone on the Internet can see your server (checking with an open open port / telnet from another network is a good test)

+2
source

All Articles