问题描述
setSocketTimout
、setConnectTimout
和 setConnectionRequestTimeout
有什么区别?
What is the difference between setSocketTimout
, setConnectTimout
and setConnectionRequestTimeout
?
RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT)
.setSocketTimeout(500)
.setConnectTimeout(500)
.setConnectionRequestTimeout(500)
.build();
推荐答案
Connection timeout
是与服务器的连接建立之前的超时时间.
Connection timeout
is the timeout until a connection with the server is established.
Socket timeout
是接收数据的超时时间.
setConnectionRequestTimeout
方法专门用于配置连接管理器.它返回从连接管理器请求连接时使用的超时时间(以毫秒为单位).超时值为零被解释为无限超时.
The method setConnectionRequestTimeout
however is specific for configuring the connection manager. It returns the timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of zero is interpreted as an infinite timeout.
这篇关于Apache HTTP - setSocketTimout 与 setConnectTimout 与 setConnectionRequestTimeout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!