optimusfrenk
optimusfrenk

Reputation: 1321

How to authenticate to RabbitMQ?

I want start using the rabbitmq client, to receive datas from a queue. This queue is online, and I have all the informations to create a connection to it:

I wrote an application in java to create a connection using the ConnectionFactory class:

import com.rabbitmq.client.ConnectionFactory;


public class Stats {


    public final static String TOKEN = "1234567";
    public final static String USER = "username";
    public final static String HOST = "amqp.host.org";
    public final static String VHOST = "topsecretdatas";
    public final static int PORT = 5672;


    public static void main(String[] args)
        throws java.io.IOException, java.lang.InterruptedException {

        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost(HOST);
        connectionFactory.setUsername(USER);
        connectionFactory.setPassword(TOKEN);
        connectionFactory.setVirtualHost(VHOST);

        connectionFactory.newConnection();
    }
}

But at the last line, an exception is raised (com.rabbitmq.client.AuthenticationFailureException). The message is:

So:

  1. Are there some log files on my PC? I think no..
  2. I don't know how to change the authentication mechanism. How can I resolve my problems and create my connection?

Upvotes: 3

Views: 16489

Answers (2)

itzMEonTV
itzMEonTV

Reputation: 20369

Is that "username" is created ? If not

So you must create a user.

sudo rabbitmqctl add_user username mypass
sudo rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
sudo rabbitmqctl set_user_tags username administrator

Upvotes: 2

andi0815
andi0815

Reputation: 130

This answer may be a late, but I had similar issues and it might be helpful to others:

  1. There are logfiles for RabbitMQ. You can find the location for instance, if you log into the management webpage and scroll down the Overview Tab. There is a section "Paths" for: Config file, Database directory, Log file& SASL log file.
    E.g. under Windows 7 the logfile can be found here: C:/Users/<USERNAME>/AppData/Roaming/RabbitMQ/log/RABBIT~1.LOG
  2. You can change the authentication mechanism. PLAIN is the default for most client, but you can also chose different ones (you might need to install plugins though). See this link for additional info: https://www.rabbitmq.com/authentication.html

Upvotes: 4

Related Questions