-
Notifications
You must be signed in to change notification settings - Fork 422
[Bug] Long time uptime workers lost the connection with RabbitMQ server #436
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
Comments
We are facing with exactly the same problem |
Hi @camiloiglesias96, there is such a problem in AMQPLazyConnection. Maybe try using AMQPStreamConnection. It helped me. |
I'm facing similar problems, although we have not identified the causes yet. |
@acosta-edgar I think the connection is disconnected at the TCP level after 60 minutes. The task in RabbitMq is returned to the queue after the connection is dropped. We get infinite processing of the task. |
@Slauta , no, that is not the case. Now, in fact, I'm seeing this issue while the job is polling the queue, not while handling the job. |
@acosta-edgar @vyuldashev @Slauta Maybe the solution at least for this package and talking about of consumer command could be add a timeout param and kill the process based using this param because this allow to supervisor bring up againg the process 💯 |
I've bumped into similar problem with It happens, because worker only restarts, when exception is considered as "lost connection". Otherwise - it will report an error and just continue. And the funny part - there is one hard-coded place which decides if exception is "lost connection" - It belongs to DB and just check error message to include one of specific phrases like:
AMQP error messages are not in that list. And there are no proper way to extend it. Ideally, all the queue-adapters should throw special exception which would be handled by worker. But we have what we have. I found workaround which worked for me:
<?php
declare(strict_types=1);
namespace App\Services\RabbitMQ;
use PhpAmqpLib\Exception\AMQPExceptionInterface;
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue;
use RuntimeException;
class FixedRabbitMQQueue extends RabbitMQQueue
{
public function pop($queue = null)
{
try {
return parent::pop($queue);
} catch (AMQPExceptionInterface $e) {
throw new RuntimeException('Lost connection: ' . $e->getMessage(), 0, $e);
}
}
} // Set to "horizon" if you wish to use Laravel Horizon.
'worker' => env('RABBITMQ_WORKER', App\Services\RabbitMQ\FixedRabbitMQQueue::class), Probably, it's better to catch only specific errors like |
Should be fixed by #457 |
Hi guys, at the moment have a RabbitMQ own instance for DEV purposes and that not receive messages everyday but the workers (Supervisor daemon using the package command) keep up running in the server. A days later i come back to the server and looking the logs the worker lost the connection and log the error
Broken pipe or closed connection {"exception":"[object] (PhpAmqpLib\\Exception\\AMQPConnectionClosedException(code: 32)
. Deeging in the error and reading some documentation of RabbitMQ and issues ofphp-amqlib
, usually this queues handlers has a concept calledheartbeat
to talk with the handler server and know if this still available and ready to receive messages from our app and i dont know if actually using the package config file we can send this signal to our server and probably avoid this error.Steps To Reproduce
The steps to reproduce this error is have a long time running the package command to consume messages and the error will appear in you log files.
Current behavior
You send a message today and is consummed by the worker then 3 days later you send again a message and this isn't consummed the worker is apparently dead the only way is restart supervisor and this works again at least in the moment.
Is the message retried or put back into the queue?
No
Is the message acknowledged or rejected?
No
Is the message unacked?
Yes
Is the message gone?
I really dont know i suppose if the message is not consummed and still in the queue, the message exist and not is gone 😄
Expected behavior
Send a message today and the worker consume the message, then send a message 3 days, 1 week or 1 month later and do just the same be consumed by the worker, thats the point 😄
Thanks a lot, have a nice weekend ❤️ 🍹
The text was updated successfully, but these errors were encountered: