moscajs / mosca

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

fix: options missing when called storage backend #630

Open eljefedelrodeodeljefe opened 7 years ago

eljefedelrodeodeljefe commented 7 years ago

Currently when you call the example redis implementations, I believe the options won't get passed through. You can easily miss this locally, as redis for example is just calling its defaults. However, setting password is silent fail.

The expectation from the redis example is that all options from the ascoltatore object gets passed down.

Though this fix fixed the redis problem I would maybe rather recommend modernisation around inheritance and option passing. But I know you know what best to do. I offer my help, as I am currently doing a lot with MQTT in a my day job.

Example:

var mosca = require('./')

var ascoltatore = {
  type: 'redis',
  redis: require('redis'),
  db: 12,
  port: 6379,
  return_buffers: true, // to handle binary payloads
  host: "localhost",
  password: 'hello'
};

var moscaSettings = {
  port: 1883,
  backend: ascoltatore,
  persistence: {
    factory: mosca.persistence.Redis
  }
};

var server = new mosca.Server(moscaSettings);
server.on('ready', setup);

server.on('clientConnected', function(client) {
    console.log('client connected', client.id);
});

// fired when a message is received
server.on('published', function(packet, client) {
  console.log('Published', packet.topic, packet.payload);
});

// fired when the mqtt server is ready
function setup() {
  console.log('Mosca server is up and running')
}
eljefedelrodeodeljefe commented 7 years ago

Currently fails due to missing backend object in some cases. Gonna be on vacation during the week. If you like to drive this forward I am gonna fix it Friday.

mcollina commented 7 years ago

I'm on vacation for the next two weeks myself.

eljefedelrodeodeljefe commented 7 years ago

Let's talk afterwards. Have a great time!

On Mon, 17 Apr 2017 at 02:06, Matteo Collina notifications@github.com wrote:

I'm on vacation for the next two weeks myself.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mcollina/mosca/pull/630#issuecomment-294381992, or mute the thread https://github.com/notifications/unsubscribe-auth/ADuBJEBotPnvqGIQdGAvWwlmia-tA6HTks5rwq0KgaJpZM4M-wUd .

-- Robert Lindstädt Berlin, Germany +49 176 701 904 78

mcollina commented 7 years ago

CI is failing everywhere: https://travis-ci.org/mcollina/mosca/jobs/222653523#L1440.