videlalvaro/php-amqplib — pull request #56 by seansullivan (2013-01-04 21:53:08+00:00)
Title: Timeouts not properly checking timeout status of stream connection when performing reading and writing.

When reading and writing to the socket, it is possible for the RabbitMQ server to block the connection, causing a 504 Gateway Error to be thrown by the server due to an infinite loop. This occurs when RabbitMQ's flow control kicks in and causes all of the connections to block. I specifically ran into this on my development server when disk-based flow control was triggered due to a lack of free disk space.

The best way to reproduce the issue is to set your rabbitmq.config file with the following rule and restart the server.

`[{rabbit, [{disk_free_limit, 1000000000000000000000}]}].`

Upon connecting to RabbitMQ from your PHP script, you will notice, in the RabbitMQ admin, that all of the connections coming from the producer are of the "blocked" type. This causes the PHP process to infinitely loop in the writing and reading logic.

The bad behavior manifests itself when attempting to close the channel & connection. This is not possible. By appropriately using the timeout value socket when the socket connection is created, the infinite loop goes away and a descriptive Exception is now thrown in both cases.

Also, the library now throws an Exception if it cannot properly set a timeout value for the socket.

This problem was also exposed in this issue: https://github.com/videlalvaro/php-amqplib/issues/43