简体   繁体   English

当服务器在调用粗麻布时出现问题(可能是套接字重置)时,释放客户端将永远挂起

[英]Release client hangs forever when server has issue (may be socket reset) during calling hessian

I have a client calls to a server through Hessian. 我有一个客户通过Hessian呼叫服务器。 During that time the server is not stable and ussually have Socket reset error. 在此期间,服务器不稳定,通常会出现套接字重置错误。 And the client was hangs at the below log. 和客户端挂在下面的日志。 So how can I release this log but still keep the application running. 因此,如何释放此日志,但仍保持应用程序运行。 And what is the reason that make the client hang forever? 而使客户端永远挂起的原因是什么? Thanks 谢谢

at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(Unknown Source) at java.io.BufferedInputStream.fill(Unknown Source) at java.io.BufferedInputStream.read1(Unknown Source) at java.io.BufferedInputStream.read(Unknown Source) - locked <0x2159c988> (a java.io.BufferedInputStream) at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 在java.net.SocketInputStream.socketRead0(本机方法)在java.net.SocketInputStream.read(未知源)在java.io.BufferedInputStream.fill(未知源)在java.io.BufferedInputStream.read1(Java未知) .io.BufferedInputStream.read(未知来源)-在sun.net.www.http.HttpClient.parseHTTPHeader(未知来源)处在sun.net.www.http.HttpClient处锁定<0x2159c988>(java.io.BufferedInputStream)。在sun.net.www.http.HttpClient.parseHTTPHeader(未知源)处在sun.net.www.http.HttpClient.parseHTTP在sun.net.www.protocol.http.HttpURLConnection处解析HTTP(未知源)。 getInputStream(未知来源)

By default HttpUrlConnection has no timeouts. 默认情况下,HttpUrlConnection没有超时。 You need to set java system properties for this: 您需要为此设置java系统属性:

http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)

Set it from command line: 从命令行设置:

-Dsun.net.client.defaultReadTimeout=30000 -Dsun.net.client.defaultConnectTimeout=30000

Or from Java code: 或从Java代码:

System.setProperty("sun.net.client.defaultReadTimeout", "30000");
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM