我和这个家伙[Link Here]
有同样的网络问题大多数网络要求在2g / 3g模式下工作正常,只有通过Wifi连接时才会出现问题。
但是我的iphone4,5 /网络浏览器上的一切都运行良好,我无法弄清楚它的问题是什么。
所以,任何帮助将不胜感激!感谢
这是代码
//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;
}
}
这是日志
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)
我试图使用androidhttpclient / apache.httpclient / basic-http-client ...等,最终他们抛出了超时异常
答案 0 :(得分:1)
确保在您的清单中使用互联网权限,并且该链接是正确的,并且可能由于网络流量而发生,这些是您的案例常见的3个问题。