java.net.sockttimeout_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().

*

*@paramtimeout an {@codeint} that specifies the timeout

* value to be used in milliseconds

*@throwsIllegalArgumentException if the timeout parameter is negative

*

*@see#getReadTimeout()

*@seeInputStream#read()

*@since1.5*/

public void setReadTimeout(inttimeout) {if (timeout < 0) {throw new IllegalArgumentException("timeout can not be negative");

}

readTimeout=timeout;

}

/*** Defines the socket timeout ({@codeSO_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 intgetSocketTimeout() {returnsocketTimeout;

}

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

2. connectionRequestTimeOut:指从连接池获取到连接的超时时间,如果是非连接池的话,该参数暂时没有发现有什么用处

3. socketTimeOut:指客户端和服务进行数据交互的时间,是指两者之间如果两个数据包之间的时间大于该时间则认为超时,而不是整个交互的整体时间,比如如果设置1秒超时,如果每隔0.8秒传输一次数据,传输10次,总共8秒,这样是不超时的。而如果任意两个数据包之间的时间超过了1秒,则超时。

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

1.RequestConfig 的配置

2.sockettimeout

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值