春季黑森州客户端套接字连接重置 [英] spring hessian client socket connection reset

查看:277
本文介绍了春季黑森州客户端套接字连接重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用spring 3.1.0,com.springsource.com.caucho-3.2.1.jar和tomcat-6.0.33双方(客户端/服务器).除了需要长时间服务(超过9/10分钟)之外,所有远程服务呼叫都可以正常工作,没有任何问题.

I am using spring 3.1.0, com.springsource.com.caucho-3.2.1.jar and tomcat-6.0.33 both sides (client/server). All the remote service calls are working fine without any issues except long time taking services(more then 9/10 minutes).

我正在使用Spring-Security保护远程呼叫.

I am using Spring-Security to protect remote calls.

我创建了一个新的远程服务,该过程大约需要30分钟才能真正反映出客户的反应.如果执行时间少于9.xx/10分钟,但服务达到9.xx/10分钟后,该服务将正常运行.在我的Hessian客户端上,我得到连接重置.

I have created a new remote service that takes approx 30 minutes to make a response to client in real schenerio. The service works perfectly if time taken of execution is less then 9.xx/10 minutes but after reaching to 9.xx/10 minutes, I am getting Connection reset on my Hessian Client.

客户端配置

<bean id="someService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
    <property name="serviceUrl" value="http://hostname:8080/remoting/someService"/>
    <property name="serviceInterface" value="com.SomeService"/>
    <property name="username" value="${service.username}"/>
    <property name="password" value="${service.password}"/>
</bean>

服务器配置

<bean id="someService" class="com.SomeService" />

<bean name="/someService" class="org.springframework.remoting.caucho.HessianServiceExporter">
    <property name="service" ref="someService" />
    <property name="serviceInterface" value="com.SomeService" />
</bean>

客户端-堆栈跟踪:

2013-Feb-28 17:48:19 DEBUG [http-8080-1] com.SomeService:85 - Calling Some Service
2013-Feb-28 17:58:16 ERROR [http-8080-1] com.SomeService:113 - 
org.springframework.remoting.RemoteConnectFailureException: 
Cannot connect to Hessian remote service at [http://hostname:8080/remoting/someService]; 
nested exception is com.caucho.hessian.client.HessianConnectionException: 
500: java.net.SocketException: Connection reset
at org.springframework.remoting.caucho.HessianClientInterceptor.convertHessianAccessException(HessianClientInterceptor.java:262)

服务器端-Tomcat(localhost.log)

SEVERE: Servlet.service() for servlet [remoting] in context with path [/JTService] 
threw exception [Hessian skeleton invocation failed; nested exception is
ClientAbortException:  java.net.SocketException: Connection reset] with root cause
java.net.SocketException: Connection reset
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)

我尝试将HessianProxyFactoryBean下的readTimeout值设置为30分钟,但在9.xx/10分钟后得到了相同的异常.但是,当我尝试使用readTimeout 2分钟时,我在2分钟后发现读取超时.

I tried to set 30 minutes value of readTimeout available under HessianProxyFactoryBean but getting the same exception after 9.xx/10 minutes. However when i tried with readTimeout 2 minutes I am getting Read timed out after 2 minutes.

将readTimeout设置为2分钟后,我得到了:

After setting readTimeout to 2 minutes I am getting :

2013-Feb-28 17:44:10 ERROR [http-8080-1] com.SomeService:113 - org.springframework.remoting.RemoteConnectFailureException: 
Cannot connect to Hessian remote service at [http://hostname:8080/remoting/someService]; 
nested exception is com.caucho.hessian.client.HessianConnectionException: 500: java.net.SocketTimeoutException: Read timed out
org.springframework.remoting.RemoteConnectFailureException: 
Cannot connect to Hessian remote service at [http://hostname:8080/remoting/someService]; 
nested exception is com.caucho.hessian.client.HessianConnectionException: 500: java.net.SocketTimeoutException: Read timed out

就像readTimeout一样,我没有在 HessianProxyFactoryBean 下看到与连接超时有关的设置.

As Like readTimeout I did'nt see and setting related to connection timeout under HessianProxyFactoryBean.

请提出建议?

推荐答案

经过调试,我发现我的 Linux/CentOS服务器在几分钟后关闭了网络连接.在*/proc/sys/net/ipv4/tcp_keepalive_time *下增加连接保持活动时间后,解决了连接超时问题.

After some debugging, I found that my Linux / CentOS server was closing the network connection after some minutes. Connection timeout issue resolved after increasing connection keepalive time under */proc/sys/net/ipv4/tcp_keepalive_time*.

Linux控制台示例输出:

Linux console sample output :

以秒为单位显示保持活动时间

Shows keepalive time in seconds

[root@hostname ~]# cat /proc/sys/net/ipv4/tcp_keepalive_time 
7200

使用以下命令增加值

[root@hostname ~]# echo "21600" > /proc/sys/net/ipv4/tcp_keepalive_time

希望这对其他人也有帮助

Hope this helps others too

这篇关于春季黑森州客户端套接字连接重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆