I can't find any documentation on the default httpParams for httpclient 4.1 ?

What's the default socket timeout when I do a GET ?

5 Answers

According to the documentation, the http.socket.timeout parameter controls the SO_TIMEOUT value, and:

If this parameter is not set, read operations will not time out (infinite timeout).

4

The accepted answer is not applicable for newer versions of HttpClient. Versions 4.3.X and above use the system default which is usually 60 secs.

Taken from HttpClient javadoc.

public int getSocketTimeout() 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. A negative value is interpreted as undefined (system default). Default: -1 
1

For Apache HttpClient version 4.x upwards

int timeout = 5*60; // seconds (5 minutes) RequestConfig config = RequestConfig.custom() .setConnectTimeout(timeout * 1000) .setConnectionRequestTimeout(timeout * 1000) .setSocketTimeout(timeout * 1000).build(); HttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); 

I'm observing infinite timeout. I'm using httpclient 4.5.13 which in turn uses httpcore 4.4.13 where SocketConfig class defines default 0 (no timeout). ()

1

A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).

Default: -1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy