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

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条)

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名