setting socket timeout in both RequestConfig and SocketConfig works differently for HTTP and HTTPS

喜你入骨 提交于 2019-12-24 08:16:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!