Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMQPIOWaitException upon docker container shutdown #300

Closed
pascaldevink opened this issue Dec 20, 2017 · 4 comments · Fixed by #317
Closed

AMQPIOWaitException upon docker container shutdown #300

pascaldevink opened this issue Dec 20, 2017 · 4 comments · Fixed by #317
Labels

Comments

@pascaldevink
Copy link
Contributor

I'm running php-enqueue with the amqp-lib and rabbitmq using a docker container (both locally and in production with Kubernetes).

I'm starting the container with the following command: bin/console enqueue:consume <queue name> --setup-broker --verbose, which works beautifully.

However, when shutting down the container, the following exception is thrown:

api_webhook_1   | [2017-12-20 16:17:05] console.ERROR: Error thrown while running command "enqueue:consume stripe_webhook --setup-broker --verbose". Message: "A network error occured while awaiting for incoming data" {"error":"[object] (PhpAmqpLib\\Exception\\AMQPIOWaitException(code: 0): A network error occured while awaiting for incoming data at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php:128)","command":"enqueue:consume stripe_webhook --setup-broker --verbose","message":"A network error occured while awaiting for incoming data"} []
api_webhook_1   | [2017-12-20 16:17:05] console.DEBUG: Command "enqueue:consume stripe_webhook --setup-broker --verbose" exited with code "1" {"command":"enqueue:consume stripe_webhook --setup-broker --verbose","code":1} []
api_webhook_1   |
api_webhook_1   | In AMQPReader.php line 128:
api_webhook_1   |
api_webhook_1   |   [PhpAmqpLib\Exception\AMQPIOWaitException]
api_webhook_1   |   A network error occured while awaiting for incoming data
api_webhook_1   |
api_webhook_1   |
api_webhook_1   | Exception trace:
api_webhook_1   |  PhpAmqpLib\Wire\AMQPReader->wait() at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php:148
api_webhook_1   |  PhpAmqpLib\Wire\AMQPReader->rawread() at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php:106
api_webhook_1   |  PhpAmqpLib\Wire\AMQPReader->read() at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php:513
api_webhook_1   |  PhpAmqpLib\Connection\AbstractConnection->wait_frame() at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php:560
api_webhook_1   |  PhpAmqpLib\Connection\AbstractConnection->wait_channel() at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:217
api_webhook_1   |  PhpAmqpLib\Channel\AbstractChannel->next_frame() at /var/www/symfony/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:327
api_webhook_1   |  PhpAmqpLib\Channel\AbstractChannel->wait() at /var/www/symfony/vendor/enqueue/amqp-lib/AmqpContext.php:389
api_webhook_1   |  Enqueue\AmqpLib\AmqpContext->consume() at /var/www/symfony/vendor/enqueue/enqueue/Consumption/QueueConsumer.php:206
api_webhook_1   |  Enqueue\Consumption\QueueConsumer->consume() at /var/www/symfony/vendor/enqueue/enqueue/Symfony/Client/ConsumeMessagesCommand.php:115
api_webhook_1   |  Enqueue\Symfony\Client\ConsumeMessagesCommand->execute() at /var/www/symfony/vendor/symfony/console/Command/Command.php:252
api_webhook_1   |  Symfony\Component\Console\Command\Command->run() at /var/www/symfony/vendor/symfony/console/Application.php:872
api_webhook_1   |  Symfony\Component\Console\Application->doRunCommand() at /var/www/symfony/vendor/symfony/framework-bundle/Console/Application.php:83
api_webhook_1   |  Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/symfony/vendor/symfony/console/Application.php:233
api_webhook_1   |  Symfony\Component\Console\Application->doRun() at /var/www/symfony/vendor/symfony/framework-bundle/Console/Application.php:71
api_webhook_1   |  Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/symfony/vendor/symfony/console/Application.php:143
api_webhook_1   |  Symfony\Component\Console\Application->run() at /var/www/symfony/bin/console:33
api_webhook_1   |
api_webhook_1   | enqueue:consume [--message-limit MESSAGE-LIMIT] [--time-limit TIME-LIMIT] [--memory-limit MEMORY-LIMIT] [--setup-broker] [--idle-timeout IDLE-TIMEOUT] [--receive-timeout RECEIVE-TIMEOUT] [--skip [SKIP]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<client-queue-names>]...
api_webhook_1   |
api_rabbitmq_1  |
api_rabbitmq_1  | =INFO REPORT==== 20-Dec-2017::16:17:05 ===
api_rabbitmq_1  | closing AMQP connection <0.548.0> (172.18.0.11:41252 -> 172.18.0.6:5672, vhost: '/', user: 'guest')
moneymachine_api_webhook_1 exited with code 1

I've tried experimenting with different timeout settings, but to no avail.
There is a SignalExtension, but it seems that's only called after the exception is already thrown.

Any tips/recommendations/helpful insight?

@makasim
Copy link
Member

makasim commented Dec 21, 2017

As far as I know, it is a limitation of PHP itself. It cannot handle a signal while waiting on the socket at the same it. It throws an error.

You could find more about it here:
https://github.com/pdezwart/php-amqp#keeping-track-of-the-workers
https://github.com/rstgroup/php-signal-handler#why-dont-you-use-pcntl_signal

I've not tried that signal extension myself.

@makasim
Copy link
Member

makasim commented Dec 22, 2017

I think that interop wrapper should somehow treat those exceptions gracefully. It might be a good idea to catch it and simply return null.

@makasim makasim added bug and removed question labels Dec 22, 2017
@makasim
Copy link
Member

makasim commented Jan 5, 2018

@pascaldevink What PHP version are you using?

@pascaldevink
Copy link
Contributor Author

@makasim 7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants