Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-549

Connection string with multiple hosts will not create a valid connection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.6
    • Affects Version/s: 1.5
    • Component/s: None
    • Labels:
      None
    • Environment:
      MongoDB 2.0.2 DB running on CentOs 6.0 connecting from Windows Server 2008 R2 using the C# driver version 1.5

      We are unable to create a connection from our web server to our DB server using a connection string in any of the formats below:

      mongodb://XXXUSERXXX:XXXPASSWORDXXX@T02-VM-XXXX01.vss-eng.com,XXXUSERXXX:XXXPASSWORDXXX@T02-VM-XXXX02.vss-eng.com,XXXUSERXXX:XXXPASSWORDXXX@T02-VM-XXXX03.vss-eng.com/NH_DEVICEDATA?replicaSet=NH_Data_01

      mongodb://XXXUSERXXX:XXXPASSWORDXXX@ T02-VM-XXXX01.vss-eng.com:27017, T02-VM-XXXX02.vss-eng.com:27017/NH_DEVICEDATA
      mongodb://XXXUSERXXX:XXXPASSWORDXXX@ T02-VM-XXXX01.vss-eng.com:27017, T02-VM-XXXX02.vss-eng.com:27017/NH_DEVICEDATA?replicaSet=NH_Data_01

      We are trying to connect to a replica set of 3 seperate VM servers and the error we continue to recieve is:

      Type: MongoDB.Driver.MongoConnectionException
      Message: Unable to connect to the primary member of the replica set.
      Source: MongoDB.Driver
      InnerExceptions: System.Exception[]
      StackTrace: at MongoDB.Driver.Internal.ReplicaSetConnector.Connect(TimeSpan timeout, ConnectWaitFor waitFor)
      at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout, ConnectWaitFor waitFor)
      at MongoDB.Driver.MongoServer.ChooseServerInstance(Boolean slaveOk)
      at MongoDB.Driver.MongoServer.AcquireConnection(MongoDatabase database, Boolean slaveOk)
      at MongoDB.Driver.MongoCursorEnumerator`1.AcquireConnection()
      at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst()
      at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext()
      at MongoDB.Driver.MongoDatabase.GetCollectionNames()
      at MongoDB.Driver.MongoDatabase.CollectionExists(String collectionName)
      at VSS.Nighthawk.EntityModels.Dao.Mongo.MongoStorage`1.SetupCollection(String collectionName, IMongoCollectionOptions collectionOptions, Func`1 runCustomClassMap) in C:\TFS\Nighthawk\NH\RC\2.5.0.3_OEMDF\Server\CommonLibrary\EntityModels\Dao\Mongo\MongoStorage.cs:line 257
      at VSS.Nighthawk.EntityModels.Dao.Mongo.MongoStorage`1..ctor(IMongoCollectionOptions collectionOptions, Func`1 runCustomClassMap) in C:\TFS\Nighthawk\NH\RC\2.5.0.3_OEMDF\Server\CommonLibrary\EntityModels\Dao\Mongo\MongoStorage.cs:line 32

      We have not modified the 1.5 driver in any way.

      The replica set is correctly set up. The output of the rs.isMaster() command is below:

      PRIMARY> rs.isMaster()
      {
      "setName" : "NH_Data_01",
      "ismaster" : true,
      "secondary" : false,
      "hosts" : [
      "T02-VM-XXXX01:27017",
      "T02-VM-XXXX02:27017"
      ],
      "passives" : [
      "T02-VM-XXXX03:27017"
      ],
      "primary" : "T02-VM-XXXX01:27017",
      "me" : "T02-VM-XXXX01:27017",
      "maxBsonObjectSize" : 16777216,
      "ok" : 1
      }

      Please let us know what the issue is with the connection string capability within the Driver.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            erik_holm@trimble.com Erik Holm
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: