Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-525

C driver does not support IPv6 addresses

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.2
    • Affects Version/s: None
    • Component/s: None
    • None

      The C driver doesn't appear to support IPv6 fully.

      Launch 3 mongod instances with ipv6

      mongod --logpath ~/tmp/1.log --dbpath ~/tmp/m1/ --replSet replset --fork --port 28001 --ipv6
      mongod --logpath ~/tmp/2.log --dbpath ~/tmp/m2/ --replSet replset --fork --port 28002 --ipv6
      mongod --logpath ~/tmp/3.log --dbpath ~/tmp/m3/ --replSet replset --fork --port 28003 --ipv6
      

      Initialise replica set with [::1] as hostname

      var conf = { _id:"replset", members: [ {_id:0, host: "[::1]:28001"}, {_id:1, host: "[::1]:28002"}, {_id:3, host: "[::1]:28003"} ]}
      rs.initialize(conf)
      

      add one test record

      use temp
      db.temp.insert({})
      

      Modify just a connection string in this example on Line 18 https://github.com/mongodb/mongo-c-driver/blob/master/examples/example-client.c#L18

      const char *uristr = "mongodb://[::1]:28001/?authSource=local&replicaSet=replset";
      

      build it, run it and in output you will see

      ./example-client
      2015/02/09 14:28:08.0088: [46707]:    DEBUG:      cluster: Client initialized in replica set mode.
      2015/02/09 14:28:08.0088: [46707]:    DEBUG:      cluster: Reconnecting to replica set.
      2015/02/09 14:28:08.0089: [46707]:    DEBUG:      cluster: Registering potential peer: [::1]:28001
      2015/02/09 14:28:08.0089: [46707]:    DEBUG:      cluster: Registering potential peer: [::1]:28002
      2015/02/09 14:28:08.0089: [46707]:    DEBUG:      cluster: Registering potential peer: [::1]:28003
      2015/02/09 14:28:08.0089: [46707]:  WARNING:      cluster: Failed to parse host and port: "[::1]:28003"
      2015/02/09 14:28:08.0089: [46707]:  WARNING:      cluster: Failed to parse host and port: "[::1]:28002"
      2015/02/09 14:28:08.0089: [46707]:  WARNING:      cluster: Failed to parse host and port: "[::1]:28001"
      Cursor Failure: No acceptable peer could be found.
      

            Assignee:
            mira.carey@mongodb.com Mira Carey
            Reporter:
            david.hows David Hows
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: