4

I'm quite new with RabbitMQ and I've got to implement a .NET client that needs to publish messages to an Exchange entity on a RabbitMQ server hosted by a third party.

The connection to the server seems to work well but then, things are gettings worse when I want to declare a channel to the Exchange I have to use.

using (var connection = connectionFactory.CreateConnection())
{
    IModel model = connection.CreateModel();
    model.ExchangeDeclare(exchangeName, ExchangeType.Direct);
    // ... the rest of the code is never reached
}

With these lines, I get an exception from the server with this message

The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=403, text="ACCESS_REFUSED - access to exchange ... in vhost ... refused for user ...", classId=40, methodId=10, cause=
 "Connection Closed, error code 403 (ACCESS_REFUSED)"

What does it mean? Does it mean that the third party which provided me with the credentials to connect to the AMQP server, hasn't granted the adequate privileges on the Exchange "exchangeName"? Or am I doing something wrong in my client? Do I really need to call ExchangeDeclare?

Thanks for the help

pierroz
  • 7,653
  • 9
  • 48
  • 60
  • `ACCESS_REFUSED` means the user you are using does not have the right permission. Are you using `guest` `guest` for a remote machine ? – Gabriele Santomaggio May 25 '16 at 14:57
  • no, I'm using the user and password provided by the third party hosting the RabbitMQ server – pierroz May 25 '16 at 14:59
  • Does function `ExchangeDeclare` have any bool parameter called `passive`? – cantSleepNow May 25 '16 at 21:10
  • 1
    @cantSleepNow in the .net client, there's a method `ExchangeDeclarePassive(string exchangeName)` – pierroz May 26 '16 at 08:13
  • Were you able to resolve this issue? I am facing the same issue while declaring an exchange after successful connection with RabbitMQ server. – VRK Jul 21 '16 at 15:29

1 Answers1

0

ExchangeDeclarePassive() method is handy in such case. When connecting to external AMQP servers, in most of the cases, there is no need to declare exchange explicitly. You just have to declare a queue and bind it to the existing exchange. The information regarding exchanges should be given to you from whatever service you are connecting to.

Niyazi Babayev
  • 120
  • 2
  • 9