[rabbitmq-discuss] How a basic cusumer of WAN know the internet connection is break?

Matthias Radestock matthias at rabbitmq.com
Mon Aug 6 11:53:45 BST 2012


On 05/08/12 10:37, Tim Watson wrote:
> Hi On 4 Aug 2012, at 20:37, luo roger <roger.maillist at gmail.com>
> wrote:
>
>> I am using pika lib.
>>
>> When I creat basic cusumer using a callback function, the broker
>> push messsages to the client,.
>>
>> client connect to the broker throught internent, but the WAN is
>> unstable. when the WAN is break, new message can't be pushed to
>> client,but client think everything is ok just no new message. Then
>> my app REST here.
>>
>> If client use baisc get in loop, it pull message from broker, when
>> the connection is break,   exception of AMQPConnectionError be
>> caused. The client can know internet is error.
>>
>> How a basic cusumer of WAN know the connection is break?
>>
>
> First of all, you should look to enable AMQP heartbeats on the
> channel, which will detect a broken connection quicker than waiting
> for the underlying tcp/ip layers to figure out what's going on.

heartbeats are probably a red herring here, since the OP *does* see 
AMQPConnectionErrors when using basic.get, so clearly broken connections 
do get detected in a reasonably timely manner.

The question is how such exceptions get reported in the case of 
basic.consume.

I am not familiar with pika so don't have a definitive answer, but 
looking at the API docs I can see an add_on_close_callback function on 
connection objects; I'd suggest giving that a try. If that doesn't work 
then please contact the pika authors (see https://github.com/pika).

Matthias.


More information about the rabbitmq-discuss mailing list