java socket 读超时,Java:socket读取超时异常

I trying to make a call to a very heavy duty process.

It's average work length is estimated by 9-10 minutes.

When I'm executing the process, I set the timeout for a ridiculously huge number: 99999999.

After 2 minutes, I get the following error:

java.net.SocketTimeoutException: Read timed out

I tried to mess with it some more, and I set the timeout to 3000, and after 3 seconds as anticipated I got the same error.

Do you have any idea on why socket.setSoTimeout(99999999) sets it to 120000 max?

解决方案

I had the same problem and the solution was not use

socket.shutdownInput(); socket.shutDownOutput(); until the last time of reading or writing data to the socket. This made the socket go to FIN_WAIT state thus waiting 2 minutes before closing. You can read more about it in this post

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值