Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ C# connection trouble when using a username and password

Tags:

c#

.net

rabbitmq

People also ask

Is RabbitMQ a library?

Overview. The RabbitMQ Java client library allows Java and JVM-based applications to connect to and interact with RabbitMQ nodes.

How do I use RabbitMQ server?

Steps to follow when setting up a connection and publishing a message/consuming a message: Set up/create a connection object. The username, password, connection URL, port, etc., will need to be specified. A TCP connection will be set up between the application and RabbitMQ when the start method is called.

What is Erlang RabbitMQ?

Written in Erlang, the RabbitMQ server is built on the Open Telecom Platform framework for clustering and failover. Client libraries to interface with the broker are available for all major programming languages. The source code is released under the Mozilla Public License.

Is RabbitMQ a UDP?

RabbitMQ "UDP Exchange" Plugin. Extends RabbitMQ Server with support for a new experimental exchange type, x-udp . Each created x-udp exchange listens on a specified UDP port for incoming messages, and relays them on to the queues bound to the exchange.


It seems that I have found a solution to my own problem. The following code works:

ConnectionFactory factory = new ConnectionFactory();
factory.UserName = "user";
factory.Password = "password";
factory.VirtualHost = "/";
factory.Protocol = Protocols.FromEnvironment();
factory.HostName = "192.168.0.12";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
IConnection conn = factory.CreateConnection();

Thanks for listening and perhaps this at least could be useful to someone else. :)


The accepted answer didn't work for me (on Windows).

I had to install the management tools:

rabbitmq-plugins enable rabbitmq_management

N.B. rabbitmq-plugins is in C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.1\sbin

Then, restart the RabbitMQ service.

I then installed EasyNetQ in Visual Studio in the package manager:

install-package easynetq

With this installed, I could use the admin web site located at:

http://localhost:15672

N.B. The default username and password is: guest

From here, I selected the Admin tab and the cause was clearly displayed in yellow at the top of the screen:

This user does not have permission to access any virtual hosts.
Use "Set Permission" below to grant permission to access virtual hosts. 

To fix the issue I just pressed the Set permission button on the same screen et voila

N.B. for this to have worked you need to have added the user using rabbitmqctl add_user username password or similar (rabbitmqctl is also in the directory above).


Here is how to create a user called agent with password agent, set it to be administrator and give it read and write access to all queues in the vhost /

rabbitmqctl add_user agent agent
rabbitmqctl set_user_tags agent administrator
rabbitmqctl set_permissions -p / agent ".*" ".*" ".*"