[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 17:20:50 BST 2011


Cool, I'll check this out and see what I can do.

--Robin

On Wed, Jun 29, 2011 at 4:42 PM, Gavin M. Roy <gmr at myyearbook.com> wrote:

> http://php.net/manual/en/function.pfsockopen.php
>
> The important thing of course will be wrapping this in an intelligent way
> keeping track of your channels and connections. In your class structure
> you'd want to know about the connection and authenticated session, channels
> and such for subsequent requests for reuse
>
> Regards,
>
> Gavin
>
> On Wed, Jun 29, 2011 at 10:56 AM, Robin Harvey <harvey.robin at gmail.com>wrote:
>
>> OK, I understand.  AFAIK, there's no way to do that in PHP without writing
>> an extension in C, is there?
>>
>>
>>
>> On Wed, Jun 29, 2011 at 2:47 PM, Gavin M. Roy <gmr at myyearbook.com> wrote:
>>
>>> Cool, I meant persistent, such as with the mysql_pconnect or
>>> pgsql_pconnect.
>>>
>>> Thanks for the work on amqphp, will look deeper at it for use in other
>>> areas. I'm glad there is an active, maintained client!
>>>
>>> Gavin
>>>
>>>
>>> On Wed, Jun 29, 2011 at 4:08 AM, Robin Harvey <harvey.robin at gmail.com>wrote:
>>>
>>>> BTW, Gavin, on this point:
>>>>
>>>>
>>>> > iirc the existing implementations do not have connection pooling
>>>>
>>>> I've recently updated amqphp so that you can manage multiple connections
>>>> at the same time, so for example you can connect to and consume from 2 or
>>>> more different brokers at the same time.  There's a demo here:
>>>>
>>>>
>>>> https://github.com/BraveSirRobin/amqphp/blob/master/demos/demo-multi-consumer.php
>>>>
>>>> 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/c3654367/attachment.htm>


More information about the rabbitmq-discuss mailing list