Binabik
Binabik

Reputation: 1073

Why does an HttpGet works without timeouts but with timeouts causes an internal server error?

I don't know how the HttpClient works exactly but I find it quite strange that I get an internal server error if I initialise the httpclient with new DefaultHttpClient(httpParameters) but everythings works fine if I initialise it with new DefaultHttpClient(). I should additionally mention that the error does not occur on the first request. Here's a piece of my code, are there any errors?

HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 3000);
HttpConnectionParams.setSoTimeout(httpParameters, 5000);
HttpClient httpclient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpclient.execute(new HttpGet(url));
int statusCode = response.getStatusLine().getStatusCode();

Upvotes: 1

Views: 98

Answers (1)

Marcin S.
Marcin S.

Reputation: 11191

Try to change

HttpClient httpclient 

to

DefaultHttpClient httpclient

Upvotes: 1

Related Questions