Search code examples
rabbitmqheartbeat

Does the RabbitMQ client have to request a heartbeat timeout, or does the server default to 60?


According to the RabbitMQ docs:

The heartbeat timeout value defines after what period of time the peer TCP connection should be considered unreachable (down) by RabbitMQ and client libraries. This value is negotiated between the client and RabbitMQ server at the time of connection. The client must be configured to request heartbeats. In RabbitMQ versions 3.0 and higher, the broker will attempt to negotiate heartbeats by default (although the client can still veto them). The timeout is in seconds, and default value is 60 (580 prior to release 3.5.5).

(https://www.rabbitmq.com/heartbeats.html)

I'm having trouble decoding the "The client must be configured to request heartbeats" sentence.

Does this mean that if the client does not request heartbeats, the heartbeat messages do not get sent? If so, what is the point of the server default?

I have looked at the Java and C# clients and they both have a client default of 60 seconds. Are there clients which do not default this?


Solution

  • From the document:

    Note that in case RabbitMQ server has a non-zero heartbeat timeout configured (which is the default in versions starting with 3.6.x), the client can only lower the value but not increase it.

    In any case there is no harm in server specifying a default. When negotiating a heartbeat the server sends clients its preference and the clients can be configured to take into account what server default is.

    https://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune

    https://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune-ok