2013-03-01 77 views
0

我使用的是spring 3.1.0,com.springsource.com.caucho-3.2.1.jar和tomcat-6.0.33双方(客户机/服务器)。除了长时间服务(超过9/10分钟)之外,所有远程服务呼叫都正常工作,没有任何问题。春天粗麻布客户套接字连接重置

我使用Spring-Security来保护远程调用。

我已经创建了一个新的远程服务,它需要大约30分钟的时间才能对真实Schenerio中的客户端做出响应。如果执行时间少于9.xx/10分钟,但在达到9.xx/10分钟后,该服务完美工作,我在我的Hessian客户端上获得连接重置

客户端配置

<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分钟后,

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

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我did'nt看到和HessianProxyFactoryBean来下,设置相关的连接超时。

请建议该怎么做?

回答

0

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

Linux控制台输出示例:

显示以下命令

[[email protected] ~]# cat /proc/sys/net/ipv4/tcp_keepalive_time 
7200 

用于增加值

[[email protected] ~]# echo "21600" > /proc/sys/net/ipv4/tcp_keepalive_time 

希望这有助于其他人也

以秒存活时间
相关问题