I get data from REST API server
using HttpClient
.
Now I should handle when I can't get any response over 10 seconds from API Server
.
So I did it like following
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);
}
It occured like
invalid use of singleclientconnmanager: connection still allocated.
It makes sense, but I don't know how to handle.