Ranjit Jena
Ranjit Jena

Reputation: 15

nodejs + mqlight connection error

I am using nodejs with mqlight to run a sample code which is provided by https://www.npmjs.com/package/mqlight.

I am using nodejs 5.5.0 and npm version is 3.3.12.

I installed mqlight using

npm install mqlight
.


    var mqlight = require('mqlight');
    var recvClient = mqlight.createClient({service: 'amqp://localhost'});
    var topicPattern = 'public';
    recvClient.on('started', function() {
      recvClient.subscribe(topicPattern);
      recvClient.on('message', function(data, delivery) {
        console.log('Recv: %s', data);
      });
    });

    var sendClient = mqlight.createClient({service: 'amqp://localhost'});

    var topic = 'public';
    sendClient.on('started', function() {
      sendClient.send(topic, 'Hello World!', function (err, data) {
        console.log('Sent: %s', data);
        sendClient.stop();
      });
    });

While I am running above code I got below error.




     E:\nodejs>node mqtest.js

    events.js:154
          throw er; // Unhandled 'error' event
          ^
     NetworkError: CONNECTION ERROR (localhost:5672): Connect failure: The remote co
    mputer refused the network connection.
        at Socket.connError (E:\nodejs\node_modules\mqlight\mqlight.js:1437:19)
        at emitOne (events.js:90:13)
        at Socket.emit (events.js:182:7)
        at emitErrorNT (net.js:1255:8)
        at nextTickCallbackWith2Args (node.js:474:9)
        at process._tickCallback (node.js:388:17)

Please help to solve this problem. I am using window 7 64 bit os.

Upvotes: 1

Views: 759

Answers (1)

dhaavhincy
dhaavhincy

Reputation: 52

Are you sure the service amqp is running? You can follow the below script to start amqp service.

START SERVICE(SYSTEM.AMQP.SERVICE)
START CHANNEL(SYSTEM.DEF.AMQP) 
REFRESH SECURITY TYPE(CONNAUTH)
DISPLAY CHSTATUS(SYSTEM.DEF.AMQP) CHLTYPE(AMQP)

Upvotes: 0

Related Questions