Saturday, June 30, 2012

[android-developers] Socket Time out

The setup

I have at home a wifi router under which I have my devices(couple of laptops,TV, Android phone and tablet). The router is connected to a cable modem provided by my ISP and all the devices share this connection.

Recently my ISP came up with an additional security system.On first connect(could be from any device) I need to authenticate myself with a username/password to my ISP website. I checked the system and they were intercepting the first http connection from my side and redirecting my browser to their login page. Some how my android browsers are not able to show this login page. I need to connect using my laptop and only later android devices can connect to internet.

My Solution
I wrote a small java application to over come this problem. It tries to connect to Intercept the redirect request and finally post my username password. The application is working fine with my laptop and I hooked it with windows start up and everything is great. Android devices still are not very happy with this app. On debugging I find that my very first socket connections is getting timed out and my application fails.

Technical Details

Device - Motorola Defy Plus

Android version - 2.3.3

Exception Socket - Time out

public class SocketHttp {

public static Socket connect(String ip) throws Exception {
Socket socket = new Socket(ip, 80);
return socket;

As I have not logged in to my ISP I am not depending on the DNS service and directly hardcoding a IP.I have added 
<uses-permission android:name="android.permission.INTERNET" /> in the Android Manifest. The code works correctly if the ISP login is completed using my lap top.

Any idea what is going wrong?

Anand G

You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment