-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 4.0.0, 4.9.1
-
Component/s: None
What problem are you facing?
Cannot connect to replica sets configured through IPv6 addresses.
What driver and relevant dependency versions are you using?
Happens with 4.0.0 and 4.9.1 driver and various versions in between, but not with latest 3.x.
Steps to reproduce?
- Add local replica set mongod configs: https://gist.github.com/addaleax/f404d9762d7d767baead1197a2f06b5e
- Prepare db: mkdir db1 && mkdir db2 && echo 'mysecretkey' > keyfile && chmod og-rwx keyfile
- Start servers: mongod --config mongod1.conf && mongod --config mongod2.conf
- Configure replicaset: mongosh 'mongodb://[::1]:27444/?directConnection=true' --eval 'rs.initiate({_id:"replset", version:1, members: [{_id:0, host:"[::1]:27444"}, {_id:1, host:"[::1]:27445"}]})'
- Attempt to connect using mongosh, Compass, or Node.js driver: mongosh 'mongodb://[::1]:27444/?directConnection=false'
This behavior does not vary when providing both rs nodes in the seed list or depending on the ?replicaSet connection string option.
Note that connecting to individual nodes using ?directConnection=true succeeds.
Relevant excerpt from a mongosh log:
{"t":{"$date":"2022-09-08T16:10:35.836Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://[::1]:27444/?directConnection=false&appName=mongosh+1.5.4","driver":{"name":"nodejs|mongosh","version":"4.8.1"},"devtoolsConnectVersion":"1.4.3","host":"::1:27444"}} {"t":{"$date":"2022-09-08T16:10:35.840Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000035,"ctx":"mongosh-connect","msg":"Server heartbeat succeeded","attr":{"connectionId":"::1:27444"}} {"t":{"$date":"2022-09-08T16:10:35.843Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"::1:27445","failure":"connection establishment was cancelled","isFailFast":false,"isKnownServer":false}} {"t":{"$date":"2022-09-08T16:11:05.854Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000037,"ctx":"mongosh-connect","msg":"Connection attempt finished"}
This is happening on Ubuntu 20.04 Linux.
- is depended on by
-
COMPASS-5947 Can't connect to ipv6 only replicaset
- Closed
- is related to
-
NODE-4621 Cannot connect to IPv6 hosts with 4.9.0+ driver
- Closed
-
MONGOSH-1294 Add IPv6 connectivity tests to the mongosh test suite
- Open