iteye_3982 2012-03-20 18:45
浏览 943
已采纳

Linux系统引起java.net.SocketException: Broken pipe的原因?

有两台linux服务器A、B
系统版本都是 Red Hat Enterprise Linux Server release 6.0 (Santiago)
JDK版本都是 1.6.0_29
在A端发布一个RMI服务,配置如下



<bean factory-method="setProperty" class="java.lang.System" lazy-init="false">
    <constructor-arg value="java.rmi.dgc.leaseValue"/>
    <constructor-arg value="300000"/>
</bean>

<bean factory-method="setProperty" class="java.lang.System" lazy-init="false">
    <constructor-arg value="java.rmi.dgc.gcInterval"/>
    <constructor-arg value="900000"/>
</bean>

<!--接收数据服务(下层模块提交的数据)-->
<bean id="eventProcessor" class="com.dataservice.EventProcessorImpl"/>

<bean id="rmiEventProcess"
   class="org.springframework.remoting.rmi.RmiServiceExporter">       <property name="serviceName" value="dataservice/eventProcessor" />
   <property name="service" ref="eventProcessor" />
   <property name="serviceInterface" value="com.dataservice.EventProcessor" />
   <property name="registryPort" value="${registryPort}"/>
   <property name="servicePort" value="${registryPort}"/>

B端为客户端,配置如下

<bean id="rmiEventProcessorClient" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
    <property name="serviceUrl" value="${targetAddr}" />
    <property name="serviceInterface"
        value="com.dataservice.EventProcessor" />
    <property name="refreshStubOnConnectFailure" value="true"></property>
</bean>

情况是这样的,B端在调用A端发布的服务时,间歇性的出现如下异常。

异常信息:error marshalling arguments; nested exception is:
java.net.SocketException: Broken pipe
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.net.SocketException: Broken pipe
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:138)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:398)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:344)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:259)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy1.handleEvent(Unknown Source)
at com.dataservice.EventSenderImpl.handleEvent(EventSenderImpl.java:220)
at com.dataservice.EventSenderImpl.sendEventTask(EventSenderImpl.java:191)
at com.dataservice.EventSenderImpl.access$0(EventSenderImpl.java:173)
at com.dataservice.EventSenderImpl$ResSendTask.run(EventSenderImpl.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847)
at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1885)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1546)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:333)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
... 22 more

补充:相同的程序,放在linux版本相同,JDK版本相同的服务器C去调用A不会出现以上问题,B、和C的防火墙策略是相同的,防火墙关了也会有这个问题,就算把服务端部署在B,B内部调用也会间歇性出现该问题。

奔溃了,搞不定啊,求解。。。。

  • 写回答

5条回答 默认 最新

  • Aronlulu 2012-03-20 19:25
    关注

    最后一个办法,tcpdump
    抓包。
    tcpdump -Xs 0 -i 网卡名如eth0 -vv -w a.cap port 端口号

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。