我有一個Loopj異步HTTP庫的奇怪問題。我有時使用GET或POST獲得響應,有時響應會在很長一段時間後出現,有時響應不會完成。這僅在使用wifi時纔會發生。我已經在很多項目中使用loopj,並且這些工作可以很好地與wifi一起工作,但不是這個項目。當我使用我的移動數據3G連接時,總會有響應。我已經覆蓋了onFaliure方法,這就是我得到的時候從服務器的響應不來:Android中的Loopj超時異常
E/statusCode(31980): 0
E/headers(31980): null
E/Throwable(31980): org.apache.http.conn.ConnectTimeoutException: Connect to .. timed out
E/errorResponse(31980): null
的例外也被印上的logcat:
04-16 10:58:18.795: W/System.err(31980): org.apache.http.conn.ConnectTimeoutException: Connect to .. timed out
04-16 10:58:18.795: W/System.err(31980): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)
04-16 10:58:18.795: W/System.err(31980): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
04-16 10:58:18.795: W/System.err(31980): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
04-16 10:58:18.795: W/System.err(31980): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
04-16 10:58:18.795: W/System.err(31980): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
04-16 10:58:18.795: W/System.err(31980): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
04-16 10:58:18.800: W/System.err(31980): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
04-16 10:58:18.800: W/System.err(31980): at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:74)
04-16 10:58:18.800: W/System.err(31980): at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:91)
04-16 10:58:18.800: W/System.err(31980): at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:54)
04-16 10:58:18.800: W/System.err(31980): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
04-16 10:58:18.800: W/System.err(31980): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-16 10:58:18.800: W/System.err(31980): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-16 10:58:18.800: W/System.err(31980): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-16 10:58:18.800: W/System.err(31980): at java.lang.Thread.run(Thread.java:841)
04-16 10:58:18.800: V/JsonHttpResponseHandler(31980): response body is null, calling onFailure(Throwable, JSONObject)
我將不勝感激,如果一些解決方案可以顯示。