[CDRIVER-525] C driver does not support IPv6 addresses Created: 10/Feb/15  Updated: 03/Apr/17  Resolved: 10/Mar/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1.2

Type: Improvement Priority: Major - P3
Reporter: David Hows Assignee: Mira Carey
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-1972 Support IPv6 only hostnames Closed

 Description   

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.



 Comments   
Comment by Githook User [ 13/Feb/15 ]

Author:

{u'username': u'hanumantmk', u'name': u'Jason Carey (hanumantmk)', u'email': u'jcarey@argv.me'}

Message: CDRIVER-525 Fix IPv6 support for replica sets

Fix _mongoc_host_list_from_string to correctly handle ipv6 addresses
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/7d8cd7347042dd6616b6503c0ce15e0760f66220

Generated at Wed Feb 07 21:09:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.