title: "PhpAmqpLib\Exception\AMQPRuntimeException: Channel connection is closed" Error with Lumen Queues
body: <p>I am using <a href="https://github.com/vladimir-yuldashev/laravel-queue-rabbitmq" rel="nofollow noreferrer">vladimir-yuldashev/laravel-queue-rabbitmq</a> library to use RabbitMq queues in Lumen project.</p>
  
  <p>The queue functionality is working fine, but I see tons of below errors in my log file.</p>
  
  <blockquote>
    <p>lumen.ERROR: PhpAmqpLib\Exception\AMQPRuntimeException: Channel connection is closed. in /var/www/html/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:227</p>
  </blockquote>
  
  <p>From the error stack trace, it seems that the queue name is taken as "NULL". Here is my rabbitmq connection configuration from <strong>queue.php</strong> </p>
  
  <pre><code>'rabbitmq'  =&gt; [
          'driver' =&gt; 'rabbitmq',
  
          'host' =&gt; env('RABBITMQ_HOST', 'rabbitmq'),
          'port' =&gt; env('RABBITMQ_PORT', 5672),
  
          'vhost'    =&gt; env('RABBITMQ_VHOST', '/'),
          'login'    =&gt; env('RABBITMQ_LOGIN', 'guest'),
          'password' =&gt; env('RABBITMQ_PASSWORD', 'guest'),
  
          'queue' =&gt; env('RABBITMQ_QUEUE'),
          // name of the default queue,
  
          'exchange_declare' =&gt; env('RABBITMQ_EXCHANGE_DECLARE', true),
          // create the exchange if not exists
          'queue_declare_bind' =&gt; env('RABBITMQ_QUEUE_DECLARE_BIND', true),
          // create the queue if not exists and bind to the exchange
  
          'queue_params' =&gt; [
              'passive'     =&gt; env('RABBITMQ_QUEUE_PASSIVE', false),
              'durable'     =&gt; env('RABBITMQ_QUEUE_DURABLE', true),
              'exclusive'   =&gt; env('RABBITMQ_QUEUE_EXCLUSIVE', false),
              'auto_delete' =&gt; env('RABBITMQ_QUEUE_AUTODELETE', false),
          ],
          'exchange_params' =&gt; [
              'name' =&gt; env('RABBITMQ_EXCHANGE_NAME', null),
              'type' =&gt; env('RABBITMQ_EXCHANGE_TYPE', 'direct'),
              // more info at http://www.rabbitmq.com/tutorials/amqp-concepts.html
              'passive' =&gt; env('RABBITMQ_EXCHANGE_PASSIVE', false),
              'durable' =&gt; env('RABBITMQ_EXCHANGE_DURABLE', true),
              // the exchange will survive server restarts
              'auto_delete' =&gt; env('RABBITMQ_EXCHANGE_AUTODELETE', false),
          ],
  
          'sleep_on_error' =&gt; env('RABBITMQ_ERROR_SLEEP', 5), // the number of seconds to sleep if there's an error communicating with rabbitmq
  
      ]
  </code></pre>
  
  <p>I am not using the default queue. Instead, each of my event listeners declare a queue for itself. Here is how I am using the queue commands to start the worker and the listeners.</p>
  
  <p><strong>worker</strong></p>
  
  <pre><code>php artisan queue:work rabbitmq
  </code></pre>
  
  <p><strong>Listeners</strong></p>
  
  <pre><code>php artisan queue:listen --queue=my-queue-1 --timeout=0
  php artisan queue:listen --queue=my-queue-2 --timeout=0
  php artisan queue:listen --queue=my-queue-3 --timeout=0
  </code></pre>
  
  <p>Each of these queue functionality is working fine.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Is it ok to start just one worker for multiple listeners?</li>
  <li>Why are my logs filled up with these errors? And how can I fix this?</li>
  </ol>
  
  <p>One more note: Not sure if it matters, my events are chained. i.e., I am firing event 2 from the event 1 listeners and so on so forth.</p>