Apache HTTP - setSocketTimout vs setConnectTimout vs setConnectionRequestTimeout

余生颓废 提交于 2019-12-19 03:15:52

问题


What is the difference between setSocketTimout, setConnectTimout and setConnectionRequestTimeout?

RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT)
            .setSocketTimeout(500)
            .setConnectTimeout(500)
            .setConnectionRequestTimeout(500)
            .build();

回答1:


Connection timeout is the timeout until a connection with the server is established.

Socket timeout is the timeout to receive data.

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.




回答2:


ConnectTimeOut:- Refers the maximum time in milliseconds client will wait for connection establishment with server. Within give time the server must have established a connection with Client other it will throw an Exception.

SocketTimeout:- It defines maximum idle/ inactivity time in milliseconds between two consecutive data packets.

refer javadocs for more details



来源:https://stackoverflow.com/questions/39256157/apache-http-setsockettimout-vs-setconnecttimout-vs-setconnectionrequesttimeout

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