2

Error: Handshake terminated by server: 403 (ACCESS-REFUSED) with message "ACCESS_REFUSED - Login was refused using authen tication mechanism PLAIN. For details see the broker logfile." I tried authMechanism individually ('PLAIN', 'AMQPLAIN', 'EXTERNAL') but i'm getting same error. Unable to create connection with rabbitMQ

var raabitmqSettings = {
    protocol: 'amqp',
    hostname: '10.250.18.31',
    port: 5672,
    username: 'sam',
    password: 'sam@123',     
    vhost: '/',
    authMechanism: ['PLAIN', 'AMQPLAIN', 'EXTERNAL']
}

amqp.connect(raabitmqSettings, function(err, conn) {
    conn.createChannel(function(err, ch) {
         console.log("\n\n" + ch);
    }   
}

Where can i see log file in rabbit mq or how enable logs in rabbitMQ?

Is it right way to create connection? Is there any setting in rabbitMQ server?

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Have you checked the RabbitMQ log? Did you create the `sam` user? What is the output of `rabbitmqctl authenticate_user sam 'sam@123'` – Luke Bakken Jul 11 '18 at 14:39
  • This one is working fine : var open = amqp.connect(raabitmqSettings); open.then(function(conn) { console.log(conn); }).then(null, console.warn); BUT I WANT TO write async and await fun @LukeBakken - Thank You – Samadhan Virkar Jul 16 '18 at 12:39
  • That is more of a javascript question than one specific to RabbitMQ or the javascript client. Now that it seems like your connection is working, you should edit your original question to reflect what you actually need assistance with. – Luke Bakken Jul 16 '18 at 17:42
  • This code working fine : `var sender = async function(setting) { const open = await amqp.connect(setting); await ch.assertExchange("ExchangeName", "direct"); var q = 'QueueName'; var msg = 'Hello World'; ch.assertQueue(q, { durable: true }); ch.sendToQueue(q, new Buffer(obj)); console.log(" [x] Sent %s", msg);` – Samadhan Virkar Aug 01 '18 at 14:00
  • Thanks @LukeBakken – Samadhan Virkar Aug 01 '18 at 14:07

1 Answers1

-1

Use following code at receiver end

const open = await amqp.connect(setting);        
    var ch = await open.createChannel();
    await ch.assertExchange("cronService", "direct");
    var q = 'CronQueue';
    ch.assertQueue(q, { durable: true });
    ch.consume(q, async function(msg) {            
        console.log(" [x] Received %s", msg.content.toString());            
    }, { noAck: true });
    return something;