Error: connect ECONNREFUSED 192.168.0.253:1883
Closed this issue · 1 comments
I may not understand exactly what mosca is. It seems to infer that I just need to npm install mosca and use. But I have tried just the following lines in a node-red function triggered at startup with mosca added globally to the settings.js:
var mosca = global.get('mosca');
var ascoltatore = {
//using ascoltatore
type: 'mongo',
url: 'mongodb://192.168.0.253:1883/mqtt',
pubsubCollection: 'ascoltatori',
mongo: {}
};
var settings = {
port: 1883,
backend: ascoltatore
};
var server = new mosca.Server(settings);
After this is run, I get:
29 Apr 16:01:41 - Error: connect ECONNREFUSED 192.168.0.253:1883
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1173:14)
I have tried using localhost and different ports and always the same error.
Ok, found this (modified for node-red) and it worked (super simple!):
var mosca = global.get('mosca');
var settings = {
port:1883
}
var server = new mosca.Server(settings);
server.on('ready', function(){
console.log("ready");
});