7
votes

I try to find out the timeout of the Apache HttpClient. The doc file* says that the default timeout for http connections is the "system default" timeout. But what is the "system default"? And how can I find out what the value for the "system default" timeout is set to?

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

Default: -1"(https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/config/RequestConfig.html#getConnectTimeout())

2

2 Answers

1
votes

System default in this particular situation means whatever socket timeout value set by the Java runtime. If the socket timeout configuration parameter is undefined, HttpClient makes no attempts to control the SO_TIMEOUT setting on connection sockets.

0
votes

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

AND

You can set default timeout by setParameter() method of HttpClient,

HttpClient httpclient = new HttpClient();
httpclient.getParams().setParameter("http.protocol.version",HttpVersion.HTTP_1_1);
httpclient.getParams().setParameter("http.socket.timeout", new Integer(1000));
httpclient.getParams().setParameter("http.protocol.content-charset", "UTF-8");