java rmi套接字连接超时没有真正尝试连接

时间:2016-04-13 07:08:21

标签: java sockets rmi

我有rmi客户端连接到不同机器上的几个rmi服务器。我有时会在客户端上获得连接超时。它是随机发生的,当我发现它并尝试再次连接到服务器时,它总是成功的。机器之间没有防火墙。

我尝试使用Wireshark捕获网络流量,并且没有来自客户端的传出SYN数据包,因此似乎没有尝试建立连接。

可能是什么原因造成的?我怎样才能知道那里发生了什么?

编辑:来自RMI的日志:

4:02:44 AM sun.rmi.transport.tcp.TCPEndpoint newSocket
FINER: task-6786: opening socket to [c1w7IE10-0059:1099]
4:02:44 AM sun.rmi.transport.proxy.RMIMasterSocketFactory createSocket
FINE: task-6786: host: c1w7IE10-0059, port: 1099

端口和主机正确但没有SYN数据包发送到主机。

编辑:stacktrace

ERROR: Error: com.kerio.at.lib.exception.KRemoteOperationFailedException: java.rmi.ConnectException: Connection refused to host: c1w7IE10-0059; nested exception is: 
    java.net.ConnectException: Connection timed out: connect
com.kerio.at.lib.exception.KRemoteOperationFailedException: java.rmi.ConnectException: Connection refused to host: c1w7IE10-0059; nested exception is: 
    java.net.ConnectException: Connection timed out: connect
    at com.kerio.at.lib.testmanager.rmi.client.TestManagerClient.connect(TestManagerClient.java:88)
    at com.kerio.at.lib.cml.scheduling.RunTestTask.connectToNode(RunTestTask.java:485)
    at com.kerio.at.lib.cml.scheduling.RunTestTask.call(RunTestTask.java:68)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.rmi.ConnectException: Connection refused to host: c1w7IE10-0059; nested exception is: 
    java.net.ConnectException: Connection timed out: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.newCall(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at java.rmi.Naming.lookup(Unknown Source)
    at com.kerio.at.lib.testmanager.rmi.client.TestManagerClient.connect(TestManagerClient.java:59)
    ... 9 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)

2 个答案:

答案 0 :(得分:0)

有几个可能的原因:

  • 外部防火墙正在阻止请求
  • 内部防火墙正在阻止请求(想想“iptables”)
  • 如果您在虚拟机上,由于虚拟网络出现间歇性或与负载相关的问题,请求将丢失
  • 这可能是一个间歇性的路由问题;例如如果您的计算机有两个网卡,那么由于配置错误的DHCP
  • ,流量可能会被错误路由
  • 您的应用程序偶尔会使用错误的IP地址;例如如果它偶尔会使用一个可能没有出现在Wireshark捕获中的环回地址。

其中一些我们可以暂时或积极地消除。但要小心,因为您对本地网络环境的了解可能不完整或过时。

答案 1 :(得分:0)

我原来是DNS问题。我关闭了dns缓存(Windows服务&#39; dns客户端&#39;),问题就消失了。

感谢bili的建议。