Friday 16 March 2018

[ASK] About NodeJS MongoDB reconnecting with EventEmitter

So this is what i do.mediator.emit('mongo.start');it will be caught by mediator.on('mongo.start') then mongodb will try to connect, and when it fail, it will emit('mongo.error')it will be caught by mediator.on('mongo.error, () => mediator.emit('mongo.start'))the problem is, when i try to this with my mongodb service turned off, it didn't do what i expected it to do. It supposed to reconnect to mongodb until it succeeds right ?? do i understand things incorrectly ?what do you usually do to handle mongodb connection failure ??thanks in advance.

Submitted March 16, 2018 at 09:05PM by StupidRandomGuy

No comments:

Post a Comment