moscajs / mosca

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

add error event for server??? #458

Closed stableShip closed 8 years ago

stableShip commented 8 years ago

using mosca-v1.2.0, when I start a mosca server with mongodb as persistence,rabbitmq as backend, my mongodb did not start , I started my mosca server , it did't show any error and the ready message. I try to listen "error" event, nothing log.How can I get the error when I start the server??

server.on('error', function(err){
    console.log(err);
});

server.on('ready', function(){
    console.log('Mosca server is up and running');
});

my settting:

var pubsubsettings = {
    type: 'amqp',
    json: false,
    amqp: require('amqp'),
    exchange: 'ascolatore5672'
};

var moscaSettings = {
    port: 1883,
    backend: pubsubsettings,
    persistence: {
        factory: mosca.persistence.Mongo,
        url: "mongodb://localhost:27017/mosca"
    }
};
mcollina commented 8 years ago

I'm sorry but I don't understand what your issue is.

stableShip commented 8 years ago

image image when my persistence config seted, but it can not connect to the mongodb.I hope the server will show me the connnect error message ,but there is nothing show

mcollina commented 8 years ago

You are right, currently Mosca is swallowing the error at startup, a callback when this async.series completes is missing.

Would you like to send a PR?

stableShip commented 8 years ago

I will try , this is my first time to make a PR to a project like this, please don't bet on me, but I will try my best.