我想将超时时间增加到5分钟,因为一分钟不足以接收回复。
我试过这两种方法:
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 80000);
HttpConnectionParams.setSoTimeout(httpParameters, 80000);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
if (isNetworkAvailable()) {
createRequest();
HttpResponse response = httpClient.execute(request);
final int code = response.getStatusLine().getStatusCode();
AndroidDefaultClient client = AndroidDefaultClient.newInstance("tets");
HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 5* 60 *1000);
HttpConnectionParams.setSoTimeout(httpClient.getParams(), 5* 60 *1000);
不幸的是,超时保持不变,但是如果我把它缩小,例如10000,它工作正常。你能帮我解决一下这个问题吗?