Avoiding maximum channels per tcp connection with amqp php, persistent connections and php-fpm

I am just learning rabbitMQ and I was having a problem.

Using http://pecl.php.net/package/amqp version 1.4 (latest now) and RabbitMQ 3.3.1. We must use php5-fpm and persistent connections with amqp-> pconnect ().

After a while (I think 65,500 queries) there is a problem with stopping all records "

Failed to create channel. The connection has no open channel slots the rest

"

From what I read in the sources, is that every tcp connection has an auto-increment channel identifier that reaches its maximum value. This is due to the fact that each request must use a channel and cannot use the same channel (I could not find the path to the php-amqp channel classes to make it permanent), and scripts cannot communicate (use one and same instance channel as php object).

To reduce php-fpm's lifetime, this is not an option, as well as decoupling application-rabbitmq communication through another technology / library, etc.

Is there an easy way to fix this?

Theoretically, it should be one channel per stream (in this case, the php5-fpm working file works), but how can this be achieved using this library?

The code I'm using now (it seems)

$this->con = new AMQPConnection(array(
    'host'          => $this->con_params['host'],
    'port'          => $this->con_params['port'],
    'vhost'         => $this->con_params['vhost'],
    'login'         => $this->con_params['user'],
    'password'      => $this->con_params['pass'],
    'read_timeout'  => 1,//seconds
    'write_timeout' => 1,//seconds
'connect_timeout' => 1,//seconds
));
$this->con->pconnect();
$channel = new AMQPChannel($this->con);
$queue = new AMQPQueue($channel);
$queue->setName($queueName);
$queue->setFlags(AMQP_DURABLE);
//$queue->declareQueue();//make sure it exists
$exchange = new AMQPExchange($channel);
$exchange->setName($exchangeName);
$exchange->setFlags(AMQP_DURABLE);
$exchange->setType(AMQP_EX_TYPE_DIRECT);
//$exchange->declareExchange();
$this->queues[$queueName]->bind($exchangeName);

Thank!

+4
1

: php-amqp connect() (, 2k + req/sec).

:

php-amqp (#define DEFAULT_CHANNELS_PER_CONNECTION 255). .

rabbitmq-c (aka librabbitmq) - #define AMQP_DEFAULT_MAX_CHANNELS 0, , , , . ( 4.9 ) :

: 16- .

wikipedia Unsigned: From 0 to 65,535. AMQP 0 .

, , , RabbitMQ , , .

, .

, , , , . php-amqp.

+5

Source: https://habr.com/ru/post/1542004/


All Articles