Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-732

Close Event if no mongos' are available

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.2.0
    • Affects Version/s: 2.1.17
    • Component/s: MongoDB 3.2
    • Environment:
      Ubuntu 16.04 with mongod and mongos in localhost

      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)

      { console.log(err, users && users.length); }

      );
      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?

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            tomallevi@gmail.com Tommaso Allevi
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: