Search code examples
androidsocketswifi4g

Android app that connects to server port 8080


So I have been developing and android application for fun in my spare time. This application opens a connection to my home server which is running a java program, does some calculations and sends a response. The issue is I do not want to use port 80. If the cell phone is on WiFi I can connect using any port that I would like, say 8080. This works from any WiFi connection even outside of my home network. However switch to 4G and the connection fails.

SERVER:8080

  • Phone on WiFi(ANY) - Works
  • Phone on 4G - Fails



SERVER:80

  • Phone on WiFi(ANY) - Works
  • Phone on 4G - Works


I switched my server over to listen on port 80 and my app to connect using the same and now the connection works on both 4G and WiFi.

Is there something I am missing to make it work on an uncommon port?

Or is this a limitation of 4G connections.

Thanks


Solution

  • I can assure you it's not an issue with 4G which is just IP connectivity. Ports are part of UDP/TCP and are just "data" to the IP network.

    However, it is possible that your cellular provider has a firewall that prevents traffic to certain ports. The PortQuiz public website listens on all ports. Using the browser on your phone, try connecting to various ports and see what is successful and what is not.

    http://portquiz.net:8080 
    http://portquiz.net:8 
    http://portquiz.net:666 
    

    If you can connect via WiFi but not Cellular, then your provider is doing things they really shouldn't.

    If the browser can connect to port 8080 of your server and your app cannot, then it's something to do with your app.