This class is not intended for use by those using Pika in their applications. This documentation is for those who are extending Pika or otherwise working on the driver itself.

Handle AMQP Heartbeats


class pika.heartbeat.HeartbeatChecker(connection, interval, idle_count=2)[source]

Checks to make sure that our heartbeat is received at the expected intervals.

_STALE_CONNECTION = 'Too Many Missed Heartbeats, No reply in %i seconds'

Return True if the connection’s heartbeat attribute is set to this instance.

:rtype True


Return the number of bytes received by the connection bytes object.

:rtype int


Returns true if the byte count hasn’t changed in enough intervals to trip the max idle threshold.


Called when a heartbeat is received


Invoked by a timer to send a heartbeat when we need to, check to see if we’ve missed any heartbeats and disconnect our connection if it’s been idle too long.


Close the connection with the AMQP Connection-Forced value.


Returns True if the connection has received data on the connection.

Return type:bool

Return a new heartbeat frame.

:rtype pika.frame.Heartbeat


Send a heartbeat frame on the connection.


Use the connection objects delayed_call function which is implemented by the Adapter for calling the check_heartbeats function every interval seconds.


If the connection still has this object set for heartbeats, add a new timer.


Update the internal counters for bytes sent and received and the number of frames received