0
在我的Android應用程序中,我運行了http post
,並且我得到了timeout
異常,當我通過3G/4G
而不是通過WiFi連接時(我發送圖像,但是這種情況發生在1 Kb的圖像上,問題不是圖像的大小,我我確信這一點)。爲什麼我的android應用程序中的Http Post在設備通過3G連接時獲取Timeout異常?
這裏的代碼。
我使用Android異步Http Client
在此先感謝。
AsyncHttpClient httpClient = new AsyncHttpClient();
RequestParams requestParams = new RequestParams();
httpClient.setTimeout(25000);
httpClient.setConnectTimeout(25000);
httpClient.setResponseTimeout(25000);
destination = new File(path);
requestParams.put("file", destination);
httpClient.post("http://" + serverUrl + ":8081/readplate", requestParams, new JsonHttpResponseHandler() {
@Override
public void onFailure(int statusCode, Header[] headers, java.lang.Throwable throwable, org.json.JSONObject response) {
//exception here
...
}
@Override
public void onSuccess(int statusCode, Header[] headers, org.json.JSONArray response) {
...
}
}
可能重複:http://stackoverflow.com/q/ 4252352分之17473617 –