I have a "producer" that's supposed to be always running, but it seems that after a day or so, it is still able to send messages to queues it has previously declared, but when trying to declare a new queue, it blows up with:
'PhpAmqpLib\Exception\AMQPHeartbeatMissedException' with message 'Missed server heartbeat' in /php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/AbstractIO.php:140
I thought that the heartbeat was only for consumers (since there's no place to check for heartbeats on producers)? Is it a bug that the heartbeat is being checked when I'm not a "consumer"?
Or is it that my script also becomes a "consumer" when I declare a queue, because it needs to "consume" feedback from the server that the queue is ready for use or something?
The way it's currently set up, what work-around could I use periodically to check if queue_declare
would blow up if it was run, so that when I do need to run queue_declare
it doesn't blow up unexpectedly?
I'm using AMQPSSLConnection
on the most recent version (2.9.2), and $connection->isConnected()
is returning true
the whole time. Heartbeat is set to 15 seconds.
It turns out the next minor release of php-amqplib
will have a method added: $connection->checkHeartBeat();
(it was committed to the project repo just days before I posted this question). Calling this regularly would solve the problem.
In the meantime, calling $connection->wait(null, true);
regularly is also a working solution.