我正在使用 spring 3.1.0、com.springsource.com.caucho-3.2.1.jar 和 tomcat-6.0.33 双方(客户端/服务器)。除了长时间使用服务(超过 9/10 分钟)外,所有远程服务调用都运行良好,没有任何问题。
我正在使用 Spring-Security 来保护远程调用。
我创建了一个新的远程服务,大约需要 30 分钟才能在真实场景中对客户端做出响应。如果执行时间少于 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 下设置 30 分钟的 readTimeout 值,但在 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 一样,我没有看到HessianProxyFactoryBean下与连接超时相关的设置。
请建议怎么做?