Java:socket读取超时异常 [英] Java: socket read time out exception
问题描述
它的平均工作长度估计为9-10分钟。
当我执行该过程时,我设置了一个可笑的巨大数字的超时时间:99999999 2分钟后,我收到以下错误:
net.SocketTimeoutException:读取超时
我尝试再混淆一些,我将超时设置为3000,之后3你有什么想法为什么 socket.setSoTimeout(99999999)
将其设置为120000最大?
我有同样的问题,解决方案没有使用
socket.shutdownInput(); socket.shutDownOutput();
,直到最后一次将数据读取或写入套接字。这使得套接字进入FIN_WAIT状态,从而在关闭之前等待2分钟。您可以在这篇文章
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
这篇关于Java:socket读取超时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!