Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ with nodejs

Am trying to establish connection with RabbitMQ from nodejs program. But its not establishing a connection, neither throwing an error. My code is as below. Any suggestions please.

var amqp = require('amqp');
var connection = amqp.createConnection({url:"amqp://guest:guest@localhost:15672"});

connection.on('ready', function(){

    var q = connection.queue('jsonmsg', function(q) {
        console.log('connected');
        q.bind("#");
        q.subscribe(function (message) { 
            console.log('on connection' + message);
        });
    }); 
});
like image 206
Abarna Sankar Avatar asked Oct 28 '13 13:10

Abarna Sankar


1 Answers

Looks like you are connecting to the management port 15672. The standard AMQP port is 5672. However, using the amqp:// protocol should automatically set this port.

So, try to change:

var connection = amqp.createConnection({url:"amqp://guest:guest@localhost"});

RabbitMQ docs for url are here.

like image 181
Davin Tryon Avatar answered Oct 05 '22 08:10

Davin Tryon