Reputation: 1127
I'm going through a RabbitMQ tutorial in node.js
Every time I run node send.js
I keep getting an error saying the econn is refused.
Here's what my code looks like:
var amqp = require('amqplib');
var when = require('when');
amqp.connect('amqp://localhost').then(function(conn){
return when (conn.createChannel().then(function(ch){
var q = 'hello';
var msg= 'Hello World!';
var ok = ch.assertQueue(q, {durable: false});
return ok.then(function(_qok){
ch.sendToQueue(q, new Buffer(msg));
console.log(" [x] Sent '%s'",msg);
return ch.close();
});
})).ensure(function() {conn.close(); });;
}).then(null,console.warn);
Here's what the error says:
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
I'm not sure what I'm doing wrong, or what I need (I'm not too experienced with node.js). But I'm pretty sure it has something to do with the localhost server. I tried googling and searching on here at stackoverflow, but nothing that I could find to my use.
Upvotes: 0
Views: 2585
Reputation: 33046
You need to start RabbitMQ-server before connecting. If you installed RabbitMQ as a system package in Linux, issue:
sudo service rabbitmq-server start
If you downloaded and unpacked it somewhere (any OS), then launch the rabbitmq-server
script you will found in the sbin/
subdirectory.
If you did not download the server, then get the appropriate package from RabbitMQ download page.
Upvotes: 4