CopernicaMarketingSoftware/AMQP-CPP

Heartbeat

Closed this issue · 4 comments

How can a connection to rabbitMQ be kept from disconnecting without sending heartbeats?

This in the read me

The proposed heartbeat interval of the server during connection setup (the server normally suggests an interval of 60 seconds) is vetoed by the AMQP-CPP library so no heartbeats are ever needed to be sent over the connection. This means that you can safely keep your AMQP connection idle for as long as you like

Not clear what the above exactly mean or how to go about it. But ur connection disconnects after a couple of minutes and we want to prevent that and we don’t want to send heartbeats. Is that possible?

According to this
https://www.rabbitmq.com/docs/heartbeats#disabling
heartbeats can be disabled by setting the timeout to 0 at connection time
Can it be done with this library?
In connection impl don't see anything directly related to connection timeout.
Does the onNegotiate() with an interval of 0 disable the heartbeats?

I just saw this

TcpConnection::TcpConnection(TcpHandler *handler, const Address &address) :

Would something like this work?

    AMQP::Address address(addressString);
    address.option("connectTimeout", 0);
    pCtrlBusConnection_.reset(new AMQP::TcpConnection(&cbeh, address));

This

    AMQP::Address address(addressString);
    address.option("connectTimeout", 0);
    pCtrlBusConnection_.reset(new AMQP::TcpConnection(&cbeh, address));

did not disable heartbeats. Connection still get disconnected. Any ideas please?

You can override the onNegotiate() method of the TcpConnectionHandler and return a value of 0, that will disable the heartbeats.