获取Rabbitmq HeartBeat异常

时间:2018-03-30 07:36:41

标签: amazon-ec2 rabbitmq amqp

我面临一个与rabbitmq有关的问题,它终止了与以下异常的连接

 {"message":"com.rabbitmq.client.AlreadyClosedException: connection is already closed due to connection error; cause: com.rabbitmq.client.MissedHeartbeatException: Heartbeat missing with heartbeat = 60 seconds"}

所以我正在使用以下配置: -

  1. 带有t2_small服务器的aws ec2-instance1上的Rabbitmq docker。

  2. 面临此问题的服务正在使用t2-small服务器的aws ec2-instance2上运行。

  3. 为rabbitmq

  4. 设置以下配置
      factory.setAutomaticRecoveryEnabled(true);
        factory.setNetworkRecoveryInterval(1000);
        factory.setRequestedHeartbeat(60);
    

    我只是无法理解导致此类错误的原因是什么,我们如何解决此问题。

    我还发现了以下来自该服务的日志,该服务试图与rabbitmq连接

      

    {“log”:“连接恢复期间发生异常!\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.632851865Z”}   {“log”:“java.net.NoRouteToHostException:无路由到主机\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.633374123Z”}   {“log”:“\ u0009at java.net.PlainSocketImpl.socketConnect(Native Method)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.633666158Z”}   {“log”:“\ u0009at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.633935828Z” }   {“log”:“\ u0009at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.634170787Z” }   {“log”:“\ u0009at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.63440824Z” }   {“log”:“\ u0009at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.634625637Z” }   {“log”:“\ u0009at java.net.Socket.connect(Socket.java:589)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00:00.635038038Z” }   {“log”:“\ u0009at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00 :00.635172903Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:34)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00 :00:00.635369445Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverConnection(AutorecoveringConnection.java:435)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00 :00:00.635639932Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:407)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00 :00:00.63584649Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access $ 000(AutorecoveringConnection.java:53)\ n”,“stream”:“stderr”,“time”:“2018-03- 22T00:00:00.636051142Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.recovery.AutorecoveringConnection $ 1.shutdownCompleted(AutorecoveringConnection.java:352)\ n”,“stream”:“stderr”,“time”:“2018-03- 22T00:00:00.636233667Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.ShutdownNotifierComponent.notifyListeners(ShutdownNotifierComponent.java:75)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00:00 :00.636899252Z“}   {“log”:“\ u0009at com.rabbitmq.client.impl.AMQConnection $ MainLoop.run(AMQConnection.java:576)\ n”,“stream”:“stderr”,“time”:“2018-03-22T00 :00:00.637183801Z“}

1 个答案:

答案 0 :(得分:1)

从我可以找到的搜索内容来看,AWS负载均衡器似乎已经关闭了连接。 您可以尝试按如下方式修改配置:

factory.setRequestedHeartbeat(30);

看看它是否解决了你的问题?