Not able to connect to RabbitMq server using a particular user

4.2k views Asked by At

I tried to connect to a particular RabbitMq machine using following code using MassTransit

var bus = ServiceBusFactory.New(x =>
      {
        x.UseRabbitMq();
        x.ReceiveFrom("rabbitmq://admin:admin@<IP Address>/somequeue");

        moreInitialization(x);
      });

I have create a user as admin in vhost "\" with administrator privileges.

cmd:> rabbitmqctl list_permissions
Listing permissions in vhost "/" ...
admin   .*      .*      .*

I have removed the "guest" user. Even though I user the below code, I can see in rabbitmq log as below

=ERROR REPORT==== 21-Jun-2015::12:19:22 ===
closing AMQP connection <0.391.0> (192.168.6.1:7000 -> 192.168.6.131:5672):
{handshake_error,starting,0,
                 {amqp_error,access_refused,
                             "PLAIN login refused: user 'guest' - invalid credentials",
                             'connection.start_ok'}}

At application side I am getting the below error

Exception:Thrown: "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile." (RabbitMQ.Client.Exceptions.AuthenticationFailureException)
A RabbitMQ.Client.Exceptions.AuthenticationFailureException was thrown: "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile."

Do I need to change any configuration in rabbitmq.config file? I am using RabbitMq Server version 3.5.3

Thanks for helping

1

There are 1 answers

0
Chris Patterson On

To specify credentials, you need to configure the host explicitly. The @ syntax is no longer supported, due to leakage of security credentials.

For example:

var bus = ServiceBusFactory.New(sbc =>
{
    sbc.UseRabbitMq(r => r.ConfigureHost(new Uri("rabbitmq://actual-server-name/queue-name"), h =>
    {
        h.SetUsername("username");
        h.SetPassword("password");
    }));
    sbc.ReceiveFrom("rabbitmq://actual-server-name/queue-name");
});