[rabbitmq-discuss] How can I set socket timeouts in PHP using the AMQP PHP extension?
Robin Harvey
harvey.robin at gmail.com
Wed Jun 29 09:03:44 BST 2011
Hi,
My own PHP / AMQP library has an API that lets you set timeouts on the
socket select function:
https://github.com/BraveSirRobin/amqphp
There's documentation here:
https://github.com/BraveSirRobin/amqphp/wiki/Documentation
If you look at the demo consumer demo file it shows you how to do this:
https://github.com/BraveSirRobin/amqphp/blob/master/demos/demo-consumer.php#L93
The easiest way to install the library is to download the 0.9.0 tag, which
includes all generated code needed to get up and running quickly.
Thanks,
--Robin
On Wed, Jun 29, 2011 at 4:08 AM, Gavin M. Roy <gmr at myyearbook.com> wrote:
> While not directly related to your question and you've not specified your
> use case, I have found trying to use native AMQP drivers in my PHP
> application as having too much overhead for connection management and iirc
> the existing implementations do not have connection pooling. This means lots
> of startup time and overhead on every request. To get around this we created
> a HTTP library that talks to the RabbitMQ JSON RPC Channel plugin. If all
> you are doing is publishing, you might want to check out VorpalBunny:
> https://github.com/myyearbook/VorpalBunny/
> As far as the underlying implementation, it's worth noting that the
> rabbitmq-c library is considered experimental. While we use it in our C
> applications in production, I can't say that we use the PHP extension on top
> of it. The PHP site has fatal errors for me right now so I can't look up to
> see which PHP extension the code is based on, otherwise I'd poke into the
> code and let you know if there are any timeout settings.
> Gavin
> On Tuesday, June 28, 2011 at 6:44 PM, Keith Krueger wrote:
> > I am using the PHP AMQP extension, as described here:
> >
> > http://php.net/manual/en/book.amqp.php
> >
> > This PHP extension uses the rabbitmq-c library as its underlying
> implementation.
> >
> > I would like to set socket timeouts for connection establishment and for
> each of my enqueues and dequeues. I want to do this in case our server
> performance degrades, to allow the clients to fail quickly rather than hang.
> >
> > Does anyone have experience doing this in a PHP environment? I have tried
> setting the PHP socket timeout as follows.
> >
> > ini_set('default_socket_timeout', 5);
> >
> > This appears to have no impact on the PHP extension's timeout settings. I
> am still able to enqueue a multi-megabyte MQ message to rabbitmq without
> losing the socket connection. It takes about 75 seconds to enqueue this
> message, but the socket is kept open the entire time.
> >
> > Is there any support either in the PHP AMQP extension or in a different
> PHP setting that I can use to reduce the timeouts for our interactions with
> RabbitMQ? I'd rather not live with a potential problem of hanging client
> processes if I can avoid it.
> >
> > Thanks,
> >
> > -Keith
> >
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-discuss at lists.rabbitmq.com (mailto:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110629/34b2e7de/attachment-0001.htm>
More information about the rabbitmq-discuss
mailing list