← Back to team overview

txamqp-dev team mailing list archive

Re: dead connections on server solved with heartbeats?

 

Hi Nate,

On 04/05/2010 01:55 PM, Nathaniel Haggard wrote:
It looks like setting heartbeats is as simple as passing heartbeat=30
to __init__ in AMQClient.  I hope that solves the rabbitmq server
problem where connections appear established even though, the client
has dropped the connection because of bad network connectivity.  This
post said heartbeats fix the issue
http://old.nabble.com/Dead-but-still-established-connections-in-RabbitMQ-on-EC2-td27433818.html.

Do the heartbeats also tell the server to do something or are they
only a client side setting.

From the standard amqp spec 0.9,
  TODO 0.82 - the heartbeat negotiation mechanism was changed during
  implementation because the model documented here does not actually
  work properly.  The best model we found is that the server proposes
  a heartbeat value to the client; the client can reply with zero, meaning
  'do not use heartbeats (as documented here), or can propose its own
  heartbeat value, which the server should then accept.  This is different
  from the model here which is disconnected - e.g. each side requests a
  heartbeat independently.  Basically a connection is heartbeated in
  both ways, or not at all, depending on whether both peers support
  heartbeating or not, and the heartbeat value should itself be chosen
  by the client so that remote links can get a higher value.  Also, the
  actual heartbeat mechanism needs documentation, and is as follows: so
  long as there is activity on a connection - in or out - both peers
  assume the connection is active.  When there is no activity, each peer
  must send heartbeat frames.  When no heartbeat frame is received after
  N cycles (where N is at least 2), the connection can be considered to
  have died. /PH 2006/07/19


So, I guess it depends of which server you work with, but at least with rabbitmq the server will honor the interval you request. txamqp *will* disconnect the server if it doesn't receive any kind of packets for (currently) 3 times the heartbeat interval you specify.

Cheers,

achuni.



References