On Android 2.1/2.2 I use DefaultHttpClient
found in Android SDK.
Apache says in their docs there are 2 timeouts:
CoreConnectionPNames.SO_TIMEOUT='http.socket.timeout': defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets). A timeout value of zero is interpreted as an infinite timeout. This parameter expects a value of type java.lang.Integer. If this parameter is not set, read operations will not time out (infinite timeout).
CoreConnectionPNames.CONNECTION_TIMEOUT='http.connection.timeout': determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout. This parameter expects a value of type java.lang.Integer. If this parameter is not set, connect operations will not time out (infinite timeout).
I tried searching Android sources for default values for these 2 timeouts, but was unable to find. Does anyone know what are the default values for these timeouts? I'd like to get a link to sources where the values are set or an official doc on this (versus just to hear an opinion).
The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period.
Connect Timeout Meaning, in general, that you cannot contact the service. Setting a low connect timeout, like 2 seconds, might be useful to prevent your application (worker, job, etc.) to remain “blocked” for a long time, as the server probably has a problem.
socket timeout — a maximum time of inactivity between two data packets when exchanging data with a server.
By default, Retrofit uses the following timeouts: Connection timeout: 10 seconds. Read timeout: 10 seconds.
Just try below below code section:
import android.net.http.AndroidHttpClient;
...
AndroidHttpClient h = AndroidHttpClient.newInstance("My http client");
// ...
Log.d(TAG, "http.socket.timeout: " + h.getParams().getParameter("http.socket.timeout"));
Log.d(TAG, "http.connection.timeout: " + h.getParams().getParameter("http.connection.timeout"));
It works on my device:
12-02 16:27:54.119 D/Exam(17121): http.socket.timeout: 60000
12-02 16:27:54.119 D/Exam(17121): http.connection.timeout: 60000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With