Answer the question
In order to leave comments, you need to log in
How to fix error in php-amqlib (RabbitMQ)?
PHP Fatal error: Uncaught PhpAmqpLib\Exception\AMQPTimeoutException: The connection timed out after 3 sec while awaiting incoming data in /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php:141
Stack trace:
#0 /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(163): PhpAmqpLib\Wire\AMQPReader->wait()
#1 /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(106): PhpAmqpLib\Wire\AMQPReader->rawread(7)
#2 /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(562): PhpAmqpLib\Wire\AMQPReader->read(7)
#3 /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(619): PhpAmqpLib\Connection\AbstractConnection->wait_frame(3)
#4 /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(234): PhpAmqpLib\Connection\AbstractConnection->wait_channel(0, 3)
#5 /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(352): PhpAmqpLib\Channel\AbstractCh in /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php on line 141
<?php
define('PROJECT_DIR', __DIR__ . '/../');
require_once __DIR__ . '/../vendor/autoload.php';
use Modules\RabbitMQ\RabbitMQ;
use Modules\Wekings\Task;
$rabbitMQ = new RabbitMQ('Run');
$callback = function ($msg) {
$runBot = new Task($msg->body);
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
};
$rabbitMQ->channel->basic_qos(null, 1, null);
$rabbitMQ->channel->basic_consume(
'Run',
'',
false,
false,
false,
false,
$callback
);
while ($rabbitMQ->channel->is_consuming()) {
$rabbitMQ->channel->wait();
}
$rabbitMQ->channel->close();
$rabbitMQ->connection->close();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question