1

I have an android app which works when I am connected to wifi, but not when I am connected through 4G. To clarify, it works when I am connected to any wifi internet connection, not the network my server is on. My manifest file contains:

<uses-permission android:name="android.permission.INTERNET" />

and the offending line is:

new Socket(InetAddress.getByName("mydomain.com"), XXXX);

which hangs and then gives me this error:

java.net.ConnectException: failed to connect to mydomain.com/XXX.XXX.XXX.XXX (port XXXX): connect failed: ETIMEDOUT (Connection timed out)

which I printed to logcat. I do not think it is a DNS problem because I successfully found the IP address with

System.out.println("Server IP:" + InetAddress.getByName("mydomain.com").toString());

I am running this on my Samsung S III phone. Again, it works fine when I am connected to wifi or when I run it in an emulator, but the client Socket times out when my internet connection is 4G. Any ideas why this would happen?

Tom
  • 35
  • 4
  • Can you reach the site from the device browser when on the mobile network? Is the site indeed on the public Internet? Perhaps your mobile and hosting ISP's are taking a business dispute out on their customers. Or perhaps the mobile carrier finds your traffic or port choice suspicious. – Chris Stratton Oct 23 '14 at 03:09
  • Yes, I also host a website on the same server and can access it from the phone on 4G. – Tom Oct 23 '14 at 19:33
  • What port are you using? What sort of traffic? How long does it take to time out? If you make your app do a pseudo-http request to your web service on port 80, does that work? The idea is to try to narrow down what the differences are, *especially* to see if there's any hint the mobile ISP blocking specific characteristics of your traffic. – Chris Stratton Oct 23 '14 at 19:36
  • Good call, I was using port 4444. If I make the socket connect to port 80, it connects. I will try using another standard port which I am not using on my server, such as port 20. Thanks! On a side note, it seems pretty ridiculous to me that Verizon would block ports from the client side. – Tom Oct 24 '14 at 15:15

0 Answers0