I have this very big mistake in my application that I really cannot solve. Whenever I make a rest call through the following code:
HttpGet request = new HttpGet(url + getParams()); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 5000); HttpConnectionParams.setSoTimeout(httpParameters, 10000); DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); httpClient.execute(request);
I get an error in DDMS:
07-15 11:22:47.448: WARN/System.err(973): org.apache.http.conn.ConnectTimeoutException: Connect to (some ip-address) timed out
But sometimes the code works fine, and I get my data as it should. I also checked the rest of the server call using a regular web browser on my computer and always return my data within 100 ms. So what am I doing wrong? I also tested it on another device, but this gives me the same problem. I would be glad if someone could solve my problem :)
source share