问题
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:
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.
来源:https://stackoverflow.com/questions/27833836/setting-socket-timeout-in-both-requestconfig-and-socketconfig-works-differently