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

Issues connecting to replica set

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.12
    • Component/s: MongoDB 3.2
    • Labels:
    • Environment:
      node v7.2.0 npm v3.10.9

      Hi everyone, since upgrading the mongodb node driver from 2.1.18 -> 2.2.12 I've noticed some funkiness when connecting to my replica set. Here is a random snippet I'm using to test:

      MongoClient.connect('mongodb://1.2.3.100:27000,1.2.4.100:27000,1.2.5.100:27000/prod?replicaSet=super-prod', {
        replSet: {
          haInterval: 500,
          socketOptions: {
            connectTimeoutMS: 5000
          }
        }
      }, function(err, db) {
        assert.equal(null, err);
        console.log("Connected successfully to server");
      
        db.close();
      });
      

      What I've noticed is on 2.1.18, the snippet will connect successfully. If I move up to 2.2.12

      AssertionError: null == ReplSet {
      domain: null,
      _events:
      { reconnect: [Function],
      timeout:

      Unknown macro: { [Function}

      ,
      err

      I was able to fix the problem though and that's kind of why this is a question, because I'm not sure if this is just an expected behavior.

      When connecting to mongodb://1.2.3.100:27000,1.2.4.100:27000,1.2.5.100:27000/prod?replicaSet=super-prod I'm seeing the library connect and then attempt to hit the replica set on its mongodbdns.com addresses.

      handleInitialConnectEvent [connect]-[1.2.3.100:27000]
      handleInitialConnectEvent [connect]-[1.2.4.100:27000]
      handleInitialConnectEvent [connect]-[1.2.5.100:27000]
      =========== connectMissingServers()
      [ '1.2.3.100:27000',
      '1.2.4.100:27000',
      '1.2.5.100:27000',
      'super-rpl-0.super.1234.mongodbdns.com:27000',
      'super-rpl-1.super.1234.mongodbdns.com:27000',
      'super-rpl-2.super.1234.mongodbdns.com:27000' ]

      Using the old client we're able to connect to the replica set using just the internal VPC ip addresses. It seems like with the new client there are initial connections to the VPC ip addresses, and then secondary connections to the resolved mongodbdns.com addresses.

      Any idea why this the case?

      Apologies if this is not the correct place for this kind of question.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dusty@chrono.gg Dustin Clark
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: