在RequestConfig和SocketConfig中设置套接字超时对HTTP和HTTPS的工作方式不同 [英] setting socket timeout in both RequestConfig and SocketConfig works differently for HTTP and HTTPS

查看:2676
本文介绍了在RequestConfig和SocketConfig中设置套接字超时对HTTP和HTTPS的工作方式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SocketConfig 中设置了套接字超时,并将SocketConfig设置为连接管理器

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

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

并通过在 RequestConfig 中将其设置为

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

参考链接

对于所有http请求,使用RequestConfig设置的新值将按预期覆盖旧值。
但是对于https请求,它总是考虑在SocketConfig中设置的旧值。

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.

我还在学习后将httpclient从4.3.1升级到4.3.6这可能是4.3.1参考链接中的一个问题。
但即使这样也无法解决问题。

我错过了什么吗?关于如何解决这个问题的任何想法?

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 ?

推荐答案

这只是部分正确。 RequestConfig 代表请求级别设置,而 SocketConfig 代表连接级别设置。安全连接需要执行SSL / TLS握手并在可用于执行请求之前建立安全会话。因此,只有在完全建立HTTPS连接后才能联合 RequestConfig 设置。在此之前只有 SocketConfig 适用。

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.

这篇关于在RequestConfig和SocketConfig中设置套接字超时对HTTP和HTTPS的工作方式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆