2
votes

I'm new to RabbitMQ. I have v3.7.7 installed. Digging through the following I have exhausted any other permissions to get pass this error.

I installed RabbitMQ locally, created a receiver, and a client to test. I'm using the default exchange and am able to read and write to queue's I create via C# code.. I installed RabbitMQ on a remote machine and tried the same and can't get either the Receiver or the Write to do any more than connect to the server. So I know the authorization is correct, but seem to be missing a permission somewhere.

On the Remote server, this is my commands used for testing:

rabbitmqctl add_vhost /els
rabbitmqctl delete_user guest
rabbitmqctl add_user gavin gavin
rabbitmqctl authenticate_user gavin gavin
rabbitmqctl set_permissions -p /els gavin "^gavin-.*" ".*" ".*"

When I execute the following:

QueueDeclareOk ok = _channel.QueueDeclare(queue.ToString(), durable, exclusive, autoDelete, null);

I get this error:

The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=403, text="ACCESS_REFUSED - access to queue 'Ping' in vhost '/els' refused for user 'gavin'", classId=50, methodId=10, cause=

Locally, even though the Ping queue doesn't exist yet, it creates it on my following BasicConsume() method. Am I missing something? Is there a way to create these queues before accessing it or do I need to add the queue via command through RabbitMQ or what?

My code for listener, which is in a function that is called multiple times, one for each queue:

//if queue exists or not, this will return 0 if there are no messages in the queue.
QueueDeclareOk ok = _channel.QueueDeclare(
                                        queue.ToString(), 
                                        durable, 
                                        exclusive, 
                                        autoDelete, 
                                        null);
//returns the number of messages in Ready state in the queue
if (ok.MessageCount > 0)
    Console.WriteLine($" ## {queue.ToString()} has {ok.MessageCount} messages in it's queue. ##");

//create a call back consumer
AsyncEventingBasicConsumer consumer = new AsyncEventingBasicConsumer(_channel);

//method to bind callback to.
consumer.Received += Consumer_Received;

//consume existing and future messages
string consumerTag = _channel.BasicConsume(queue: queue.ToString(),
                        autoAck: autoAck,
                        consumer: consumer);

//add to dictionary so it can be cancel
_consumerTag.Add(queue, consumerTag);
1

1 Answers

2
votes

Resolved it with the following:

rabbitmqctl clear_permissions -p /els gavin
rabbitmqctl set_permissions -p /els gavin ".*" ".*" ".*"