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

Connection leaking and authentication issues

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.0
    • Affects Version/s: 2.1.21
    • Component/s: None
    • Labels:
    • Environment:
      Ubuntu Server 14.04 LTS (HVM)
      Node version 4.4.3
      Driver version 2.1.21
      mongod version 3.0.11

      We are finding that the number of connections to the Primary, Secondary, and Arbiter will seemingly grow without bound over time.

      The code below reproduces this issue:

      var mongodb = require("mongodb");
      
      var uri = "mongodb://foo:bar@ds021331-a0.mlab.com:21331,ds021331-a1.mlab.com:21331/driver-test?replicaSet=rs-ds021331";
      var interval = 1000;
      
      var openThenClose = function(){
          var MongoClient = mongodb.MongoClient;
          MongoClient.connect(uri, function(err, db) {
              console.log("open");
              var descriptors = db.collection("some-collection").find();
              descriptors.toArray(function(err, docs){
                  db.close(function(){
                      console.log("close");
                  });
              });
          });
      };
      
      setInterval(function(){
          openThenClose();
      }, interval);
      

      You can test against the deployment in the script. I've also attached the log files for the Primary, Secondary, and Arbiter, which I've cleaned up to make easier to read. Note that they begin at ~2016-05-30T10:31:52.282-0700 and problems start manifesting ~3.5 hours later.

      The Primary and Secondary logs contain the following error message:

      SCRAM-SHA-1 authentication failed for foo on driver-test from client 52.207.222.58 ; BadValue Unmatched SCRAM-SHA-1 nonce received from client in second step, expected i2cVwYAl+bypiy6nm0aX+rF8fiKNL3FYe1FtUQ4lij7r7c3hYkj1J7nwqxl1L4Fa but received

      The Arbiter logs show that the driver is trying to authenticate against the server (which is not intended behavior per https://jira.mongodb.org/browse/NODE-693):

      SCRAM-SHA-1 authentication failed for foo on driver-test from client 52.207.222.58 ; UserNotFound Could not find user foo@driver-test

        1. mongodb.log.2016-05-31T09-37-24.PRIMARY
          1.73 MB
          Christopher Chang
        2. mongodb.log.2016-05-31T09-37-25.SECONDARY
          1.69 MB
          Christopher Chang
        3. mongodb.log.2016-05-31T09-37-31.ARBITER
          963 kB
          Christopher Chang

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            chrischang12 Christopher Chang
            Votes:
            9 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: