您好,欢迎来到99网。
搜索
您的当前位置:首页Http超时时间之SocketTimeout

Http超时时间之SocketTimeout

来源:99网
Http超时时间之SocketTimeout

/**

* Sets the read timeout to a specified timeout, in

* milliseconds. A non-zero value specifies the timeout when

* reading from Input stream when a connection is established to a * resource. If the timeout expires before there is data available * for read, a java.net.SocketTimeoutException is raised. A * timeout of zero is interpreted as an infinite timeout. *

*

Some non-standard implementation of this method ignores the * specified timeout. To see the read timeout set, please call * getReadTimeout(). *

* @param timeout an {@code int} that specifies the timeout * value to be used in milliseconds

* @throws IllegalArgumentException if the timeout parameter is negative *

* @see #getReadTimeout() * @see InputStream#read() * @since 1.5 */

public void setReadTimeout(int timeout) { if (timeout < 0) {

throw new IllegalArgumentException(\"timeout can not be negative\"); }

readTimeout = timeout; }

/**

* Defines the socket timeout ({@code SO_TIMEOUT}) in milliseconds, * which is the timeout for waiting for data or, put differently,

* a maximum period inactivity between two consecutive data packets). *

* A timeout value of zero is interpreted as an infinite timeout. * A negative value is interpreted as undefined (system default). *

*

* Default: {@code -1} *

*/

public int getSocketTimeout() { return socketTimeout; }

1. connectTimeOut:指建⽴连接的超时时间,⽐较容易理解

2. connectionRequestTimeOut:指从连接池获取到连接的超时时间,如果是⾮连接池的话,该参数暂时没有发现有什么⽤处3. socketTimeOut:指客户端和服务进⾏数据交互的时间,是指两者之间如果两个数据包之间的时间⼤于该时间则认为超时,⽽不是整个交互的整体时间,⽐如如果设置1秒超时,如果每隔0.8秒传输⼀次数据,传输10次,总共8秒,这样是不超时的。⽽如果任意两个数据包之间的时间超过了1秒,则超时。

线上问题:设置sockettimeout 15秒,但是实际到达156秒,线程数陡增,导致机器崩溃,具体原因有待抓包分析1.RequestConfig 的配置2.sockettimeout

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 99spj.com 版权所有 湘ICP备2022005869号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务