开发者

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

开发者 https://www.devze.com 2023-02-24 08:34 出处:网络
I have a client calls to a server through 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

I have a client calls to a server through 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(Unk开发者_StackOverflow中文版nown 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)


By default HttpUrlConnection has no timeouts. You need to set java system properties for this:

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:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号