moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Example not working !!! #746

Open abdoutech93 opened 6 years ago

abdoutech93 commented 6 years ago

When I tried to launch the Server_With_All_Interfaces-Settings.js I got this logs !!!! { Error: connect ECONNREFUSED 127.0.0.1:5672 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1170:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 5672 } Any one can help please, thank you in advance.

CurtisGreen commented 6 years ago

I did not use that example specifically so I'm not completely familiar with it, but after some checking it seems to be an issue with the pubsubSettings. I used MongoDB for mine instead of AMQP and it works well most of the time after you get mongo set up.

const mongoUrl = 'mongodb://localhost:27017/mqtt'; // Doesn't have to be mqtt
const mongoose = require('mongoose');

// Auto logs all commands to mongo
const mosca = require("mosca");
const pubsubsettings = {
    type: 'mongo',
    url: mongoUrl,
    pubsubCollection: 'ascoltatori',
    mongo: {}
};
const moscaSettings = {
    port: portNum,
    backend: pubsubsettings,
    persistence: {
        factory: mosca.persistence.Mongo,
        url: mongoUrl
    }
};