-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.1.17
-
Component/s: MongoDB 3.2
-
Environment:Ubuntu 16.04 with mongod and mongos in localhost
-
Empty show more show less
I'm looking for an event that allow me to shutdown the application in case all mongos become unavailable.
For example, with mongodb running in localhost on 27018, I run mongos with this command:
```
mongos --port 27018 --configdb 127.0.0.1:27017 -vvvvv
```
with this code:
```
'use strict';
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;
var Logger = mongodb.Logger;
var url = 'mongodb://localhost:27018/gamearena';
MongoClient.connect(url, {server: { }} function(err, db) {
db.collection('_User').find({})
.toArray(function(err, users)
);
db.on('error', console.log.bind(console, 'ERROR'));
db.on('close', console.log.bind(console, 'CLOSE'));
db.on('timeout', console.log.bind(console, 'TIMEOUT'));
});
```
No events are emitted when i kill mongos
Instead, if the code is connected to mongodb directly and kill mongo, the code is notified correctly.
I suppose this behavior is not right.
Which event should I listen?