我从中获取数据
REST API server
使用
HttpClient
。
现在,当我在10秒内无法从
API Server
。
所以我就这样做了
HttpClient httpClient = new DefaultHttpClient();
HttpParams httpParams = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 10000);
HttpConnectionParams.setSoTimeout(httpParams, 10000);
HttpPost httpPost = new HttpPost("api server address");
httpPost.setParams(...);
HttpResponse response;
try{
response = httpClient.execute(httpPost);
} catch(SocketTimeoutException e){
httpPost.setParams(...); // change param
response = httpClient.execute(httpPost);
}
事情发生的样子
invalid use of singleclientconnmanager: connection still allocated.
这很有道理,但我不知道如何处理。