Starting with STOMP 1.1, each end of a STOMP connection can check if the other end is alive via heart-beating.

In order to use heart-beating (which is disabled by default), the client must specify what it wants before sending the CONNECT frame. This can be done using the client_heart_beat and server_heart_beat options of the new() method or, this is equivalent, the client_heart_beat() and server_heart_beat() methods on the Net::STOMP::Client object.

After having received the CONNECTED frame, the client_heart_beat() and server_heart_beat() methods can be used to get the negotiated values.

To prove that it is alive, the client just needs to call the beat() method when convenient.

To check if the server is alive, the client just needs to compare the current time and what is returned by the last_received() and server_heart_beat() methods. For instance: