2

I have set socket timeout in SocketConfig and set SocketConfig to connection manager as

connManager.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(soTimeout).build())

And overwriting the socket timeout value for individual requests by setting it in RequestConfig as

httpRequest.setConfig(RequestConfig.copy(defaultRequestConfig).setSocketTimeout(timeout).build())  

Reference link.

For all http requests, the new value set using RequestConfig is overwriting the old value as expected. But for https requests it is always considering the old value which was set in SocketConfig.

I also upgraded httpclient from 4.3.1 to 4.3.6 after learning that this could be an issue in 4.3.1 reference link. But even this didn't help me solving the issue.
Am I missing anything ? Any idea on how I can solve this issue ?

1 Answer 1

5

This is only partially true. RequestConfig represents request level settings, while SocketConfig represents connection level settings. Secure connections need to do a SSL/TLS handshake and establish a secure session before they can be used to execute requests. Therefore, RequestConfig settings can be allied only after HTTPS connection has been fully established. Until then only SocketConfig apply.

Sign up to request clarification or add additional context in comments.

2 Comments

Sounds like a design flaw - without setting default socket config, client can hang forever, despite the fact that dev already took care about eg. extending default timeout period for particular request. IMHO request config (if at least the one from client context) should apply to SLL handshake!) Upvote for splitting SSL from HTTP layers.
@Antoniossss: It does. At the SSL handshake time if the connect timeout is finite and the socket timeout is undefined (infinite) the connection timeout applies github.com/apache/httpclient/blob/4.5.x/httpclient/src/main/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.