ryanfunyeah
ryanfunyeah

Reputation: 27

Weird Android ConnectTimeoutException

I got a same network issue with this dude [Link Here]

most network requirements working fine in 2g/3g mode, problem occurs only when connected via Wifi.

but everything work nicely on my iphone4,5/web browser , i can't figure out what's the problem with it.

so ,any help would be greatly appreciated! Thanks

here's the code

    //Code in HttpHelper.java
    public class HttpHelper{
        ..................
        HttpGet get = new HttpGet(url);//295
        HttpResult result = new HttpResult();
        HttpClient client = getNewHttpClient();
        HttpResponse response = client.execute(httpPost);// line 298

        ..................
        public static HttpClient getNewHttpClient() {
            return new DefaultHttpClient();
        }

        ..................
    }


    //Code in HttpResult.java
    public class HttpResult {
        public int code;
        public String response;

        public HttpResult(){
            this.code = HttpStatusCode.FAIL;
            this.response = null;
        }
    }

here's the log

10-30 11:18:18.672: W/System.err(945): org.apache.http.conn.ConnectTimeoutException: Connect to /188.151.209.58:80 timed out
10-30 11:18:18.682: W/System.err(945):  at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)
10-30 11:18:18.682: W/System.err(945):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
10-30 11:18:18.682: W/System.err(945):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
10-30 11:18:18.682: W/System.err(945):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
10-30 11:18:18.682: W/System.err(945):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
10-30 11:18:18.682: W/System.err(945):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-30 11:18:18.687: W/System.err(945):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-30 11:18:18.687: W/System.err(945):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
10-30 11:18:18.687: W/System.err(945):  at my.package.name.manager.http.HttpHelper.getResponse(HttpHelper.java:298)
10-30 11:18:18.687: W/System.err(945):  at my.package.name.manager.http.HttpHelper.getData(HttpHelper.java:175)
10-30 11:18:18.687: W/System.err(945):  at my.package.name..util.ThreadUtil$TaskRunnable.run(ThreadUtil.java:209)
10-30 11:18:18.687: W/System.err(945):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-30 11:18:18.687: W/System.err(945):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-30 11:18:18.692: W/System.err(945):  at java.lang.Thread.run(Thread.java:856)

i tried to using androidhttpclient/apache.httpclient/basic-http-client...etc,eventually they throw me a timeout exception both

Upvotes: 0

Views: 1254

Answers (1)

Make sure to use the internet permission in your manifest, and the link is correct, and maybe it will happen because of network traffic, those are the common possible 3 issues for your case.

Upvotes: 1

Related Questions