rabbitmq报Heartbeat missing with heartbeat = 60 seconds

96
扎北
2018.08.14 16:51 字数 798

2018-07-29 10:20:15.018 ERROR [rabbitmq-nio] c.r.c.impl.ForgivingExceptionHandler-- An unexpected connection driver error occured
com.rabbitmq.client.MissedHeartbeatException: Heartbeat missing with heartbeat = 60 seconds
at com.rabbitmq.client.impl.AMQConnection.handleHeartbeatFailure(AMQConnection.java:648)
at com.rabbitmq.client.impl.nio.NioLoop.run(NioLoop.java:78)
at java.lang.Thread.run(Thread.java:745)
2018-07-29 10:20:30.055 ERROR [rabbitmq-nio] c.r.c.impl.ForgivingExceptionHandler-- Caught an exception during connection recovery!
java.util.concurrent.TimeoutException: null
at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:120)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
at com.rabbitmq.client.impl.AMQChannelBlockingRpcContinuation.getReply(AMQChannel.java:372) at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:297) at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62) at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverConnection(AutorecoveringConnection.java:531) at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:494) at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access000(AutorecoveringConnection.java:53)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection$1.recoveryCanBegin(AutorecoveringConnection.java:435)
at com.rabbitmq.client.impl.AMQConnection.notifyRecoveryCanBeginListeners(AMQConnection.java:693)
at com.rabbitmq.client.impl.AMQConnection.doFinalShutdown(AMQConnection.java:687)
at com.rabbitmq.client.impl.AMQConnection.handleHeartbeatFailure(AMQConnection.java:654)
at com.rabbitmq.client.impl.nio.NioLoop.run(NioLoop.java:78)
at java.lang.Thread.run(Thread.java:745)
阅读了官方文档和查看了客户端源代码,心跳默认超时时间是60秒,并且每隔30秒进行一次心跳检查,如果超过两次心跳检查都没有确定节点检查,则会关闭这次的连接,之后必须重新连接.
ConnectionFactory类中:
/** Default heart-beat interval;
* 60 seconds */
public static final int DEFAULT_HEARTBEAT = 60;

心跳机制可以参考:
https://www.cnblogs.com/Tommy-Yu/p/5775852.html

心跳超时值决定了tcp相互连接的最大时间, 超过了这个时间, 该连接即被RMQ和客户端视为丢失(dead)。 这个值在客户端和服务器建立连接的时候协商确定。客户端需配才能发心跳包。 RMQ3.0及以上版本, RMQ将试着将beatheart协调为默认值(客户端可以否决这个值)。 超时时间单位为秒,默认值为60( 3.5.5发布版之前是580)。

Heartbeat frames are sent about every timeout / 2 seconds. After two missed heartbeats, the peer is considered to be unreachable. Different clients manifest this differently but the TCP connection will be closed. When a client detects that RabbitMQ node is unreachable due to a heartbeat, it needs to re-connect.

心跳包每半个超时时间发送一次。 丢失了两个心跳包, 连接被认为不可抵达。 不同的客户端有不同的提示, 但tcp连接都会被关闭。 当客户端检测到RMQ节点不可抵达(根据心跳判定), 它需要重新连接(到服务器)。

Heartbeats can be disabled by setting the timeout interval to 0.

心跳机制可以被禁用:设定超时间隔为0。

是什么原因造成超时的能,排查了下系统资源,在超时的时间,服务器网卡占用很高,但是其他系统连接mq没有问题。可以排除是网卡的问题。
跟运维排查,是由于mq发生了脑裂造成集群的不稳定,而自己的应用配置的是单节点,导致心跳超时后不能重新连接到集群内其他可以的节点

参考地址:
https://blog.csdn.net/mosee/article/details/80990120

https://www.cnblogs.com/sellsa/p/8046156.html

https://www.cnblogs.com/binchen-china/p/5708381.html

https://blog.csdn.net/aa292016616/article/details/81390770

https://blog.csdn.net/youbl/article/details/79024061

日记本