[rabbitmq-discuss] Best way to ping server from client

James Gardner james.gardner at noaa.gov
Tue Dec 17 17:18:56 GMT 2013

Hi Alvaro,

Great to get your reply, I didn't expect to hear from the Creator ;). 
Sorry about the delay, I wanted to think further on this before responding.
The access_request idea was the type of answer I was looking for, but alas:
...so I can't base a solution on it.

The way I'm understanding it, there is a fundamental problem, when 
waiting for a server-push, in being able to detect the difference 
between 'server has nothing to send you' and 'server has just gone away 
forever', hence the need for some sort of heartbeat.
I guess I have come to the conclusion that the only way to tell if a 
server has gone away, is to send a request which should illicit an 
immediate response, hence the need for some sort of ping.
There are only two operations I can think of to use for pings, albeit 
relatively expensive ones:

For consume scripts, a periodic queue declaration call, since they're 
For publish scripts, a periodic QOS call, eg. setting prefetch number? 
(Am I correct in saying this would have no effect on a channel used only 
for publishing?)

Do you or anyone else see any problems with using these? Let me know if 
my thinking is off somehow.

Also, if you would care to, I would like to ask you to comment on:
Not sure I fully understand the exact implications or limitations that 
result from this issue; what are the scenarios in which this would cause 
a problem?

I would like to take the opportunity to thank you and all the 
contributors for a great library; it's been a real life saver since we 
were suffering a memory leak in the PECL AMQP extension. PhpAmqpLib has 
been very solid so far and I greatly prefer its design. It's also nice 
to be able to read the code easily, and package it along with our apps.


On 12/09/2013 11:49 AM, Alvaro Videla wrote:
> Hi James,
> I've thought about implementing some of the hearbeats exposed by
> RabbitMQ but is not so easy considering PHP's single thread view of
> the world. I could try to approximate timeouts for example, but not
> sure about what errors that could bring.
> As a complete hack and trying to answer your question, there's the
> access_request method which in RabbitMQ won't do much: See
> https://github.com/videlalvaro/php-amqplib/blob/master/PhpAmqpLib/Channel/AMQPChannel.php#L233
> andhttp://hg.rabbitmq.com/rabbitmq-server/file/3e9ad0a5795e/src/rabbit_channel.erl#l646
> Regards,
> Alvaro
> On Mon, Dec 9, 2013 at 6:42 PM, James Gardner<james.gardner at noaa.gov>  wrote:
>> Hi,
>> I need to know the best way to 'ping' an AMQP server from a client (I'm
>> using PhpAmqpLib). We have encountered some situations where the client
>> doesn't realize the server has 'gone away', and hangs for far too long,
>> sometimes indefinitely. Regardless of whether this is a problem with the
>> client library, if I wanted to test the connection by issuing the most
>> benign, inexpensive request, what might that be? Perhaps there is a channel
>> method I can call repeatedly at regular intervals without causing errors,
>> like QOS, or something else? This would be during a consume.
>> Thanks,
>> James Gardner, NWS NIDS
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

More information about the rabbitmq-discuss mailing list