Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android DefaultHttpClient default timeout

Tags:

android

http

My questions is what is default timeout for requests made with DefaultHttpClient if I didn't specify it.

So if don't have code like this

HttpParams my_httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(my_httpParams, 3000);
HttpConnectionParams.setSoTimeout(my_httpParams, 1);

but just

HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setContentCharset(params,
                HTTP.DEFAULT_CONTENT_CHARSET);
ClientConnectionManager cm = new ThreadSafeClientConnManager(params,
                schemeRegistry);
SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory
                .getSocketFactory(), 80));
return new DefaultHttpClient(cm, params);

How long will this httpClient wait for response from server?

like image 355
Robert Avatar asked Oct 16 '25 17:10

Robert


1 Answers

As far as I know the connection timeout and socket timeout for the DefaultHttpClient are both null (or zero) by default, which means that the timeouts are not used and Android application will wait theoretically forever for both the connection and socket response to complete. Therefore, it is highly recommended that to provide new connection and socket timeouts when using the DefaultHttpClient.

like image 179
Saifuddin Sarker Avatar answered Oct 18 '25 08:10

Saifuddin Sarker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!