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);
});
});
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With