-
Notifications
You must be signed in to change notification settings - Fork 4
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
Channel connection is closed when consume #13
Comments
Here's my amqp.php config file <?php
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
$amqp = parse_url(env('CLOUDAMQP_URL'));
return [
'default' => env('AMQP_CONNECTION', 'rabbitmq'),
'connections' => [
'rabbitmq' => [
'connection' => [
'class' => AMQPStreamConnection::class,
'hosts' => [
[
'host' => $amqp['host'],
'port' => array_key_exists("port", $amqp) ? $amqp['port'] : 5672,
'user' => $amqp['user'],
'password' => $amqp['pass'],
'vhost' => ltrim($amqp['path'], '/') ?: '/',
]
],
'options' => [],
],
'message' => [
'content_type' => env('AMQP_MESSAGE_CONTENT_TYPE', 'text/plain'),
'delivery_mode' => env('AMQP_MESSAGE_DELIVERY_MODE', AMQPMessage::DELIVERY_MODE_PERSISTENT),
'content_encoding' => env('AMQP_MESSAGE_CONTENT_ENCODING', 'UTF-8'),
],
'exchange' => [
'name' => env('AMQP_EXCHANGE_NAME', 'amq.direct'),
'declare' => env('AMQP_EXCHANGE_DECLARE', false),
'type' => env('AMQP_EXCHANGE_TYPE', 'direct'),
'passive' => env('AMQP_EXCHANGE_PASSIVE', false),
'durable' => env('AMQP_EXCHANGE_DURABLE', true),
'auto_delete' => env('AMQP_EXCHANGE_AUTO_DELETE', false),
'internal' => env('AMQP_EXCHANGE_INTERNAL', false),
'no_wait' => env('AMQP_EXCHANGE_NOWAIT', false),
'arguments' => [],
'ticket' => env('AMQP_EXCHANGE_TICKET'),
],
'queue' => [
'name' => env('AMQP_QUEUE_NAME', 'amqp.laravel.queue'),
'declare' => env('AMQP_QUEUE_DECLARE', false),
'passive' => env('AMQP_QUEUE_PASSIVE', false),
'durable' => env('AMQP_QUEUE_DURABLE', true),
'exclusive' => env('AMQP_QUEUE_EXCLUSIVE', false),
'auto_delete' => env('AMQP_QUEUE_AUTO_DELETE', false),
'no_wait' => env('AMQP_QUEUE_NOWAIT', false),
'arguments' => [],
'ticket' => env('AMQP_QUEUE_TICKET'),
],
'consumer' => [
'tag' => env('AMQP_CONSUMER_TAG', ''),
'no_local' => env('AMQP_CONSUMER_NO_LOCAL', false),
'no_ack' => env('AMQP_CONSUMER_NO_ACK', false),
'exclusive' => env('AMQP_CONSUMER_EXCLUSIVE', false),
'no_wait' => env('AMQP_CONSUMER_NOWAIT', false),
'arguments' => [],
'ticket' => env('AMQP_CONSUMER_TICKET'),
],
'qos' => [
'enabled' => env('AMQP_QOS_ENABLED', false),
'prefetch_size' => env('AMQP_QOS_PREFETCH_SIZE', 0),
'prefetch_count' => env('AMQP_QOS_PREFETCH_COUNT', 1),
'global' => env('AMQP_QOS_GLOBAL', false),
],
'publish' => [
'mandatory' => false,
'immediate' => false,
'ticket' => null,
'batch_count' => 500,
],
'bind' => [
'no_wait' => false,
'arguments' => [],
'ticket' => null,
],
'consume' => [
'allowed_methods' => null,
'non_blocking' => false,
'timeout' => 0,
],
],
],
]; |
Hello @alesima Can you check the solution from the SO and confirm if it works. https://stackoverflow.com/questions/8839094/why-do-my-rabbitmq-channels-keep-closing |
Hi When publishing a message inside a receiver callback, it uses the same Quoting https://www.cloudamqp.com/blog/part4-rabbitmq-13-common-errors.html :
Don't really know what would be the best option to fix that... Maybe we can create 2 connections (with same config) when we instantiate |
@tof06 I am again sorry for the late reply due to unavoidable circumstances. Can you share a working code that breaks the connection? Also, publishing is mostly done from the web requests, and can also be published from the jobs. As soon as the request or job is done, the connection is closed and the consumption should be done in a long-running command, where the connection is kept alive. So, it uses two different connection to publish and consume the data. Am I missing anything here? |
I'm getting "Channel connection is closed" when consuming some queue.
Any thoughts?
The text was updated successfully, but these errors were encountered: