-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 1.0.3
-
Component/s: Connectivity
-
None
-
1
-
Iteration Hamburg
-
Not Needed
Problem Statement/Rationale
Invoking mongosh with --host rs/host --port xx does not use port xx to contact the replica set
Steps to Reproduce
first create a 3 member replica set on 3 different ports, I use 27017/27018/27019
then shut down the member on port 27017
[admin@desktop repros]$ mongosh --host m/mongodb-local.computer --port 27018 --username admin --password tester --authenticationDatabase admin Current Mongosh Log ID: 6109928468d46e2b9b6983d9 Connecting to: mongodb://mongodb-local.computer/?replicaSet=m MongoNetworkError: connect ECONNREFUSED 127.0.2.1:27017 [admin@desktop repros]$
Expected Results
expect it to connect to the replica set via port 27018
here's how legacy shell handles it
[admin@desktop repros]$ mongo --host m/mongodb-local.computer --port 27018 --username admin --password tester --authenticationDatabase admin mongo: /usr/lib/libsasl2.so.2: no version information available (required by mongo) MongoDB shell version v4.0.25 connecting to: mongodb://mongodb-local.computer:27018/?authSource=admin&gssapiServiceName=mongodb&replicaSet=m 2021-08-03T14:04:19.511-0500 I NETWORK [js] Starting new replica set monitor for m/mongodb-local.computer:27018 2021-08-03T14:04:19.530-0500 I NETWORK [js] Successfully connected to mongodb-local.computer:27018 (1 connections now open to mongodb-local.computer:27018 with a 10 second timeout) 2021-08-03T14:04:19.530-0500 I NETWORK [js] changing hosts to m/mongodb-local.computer:27017,mongodb-local.computer:27018,mongodb-local.computer:27019 from m/mongodb-local.computer:27018 2021-08-03T14:04:19.530-0500 I NETWORK [js] mongodb-local.computer:27018 detected as new replica set primary for m; Old primary was :27017 2021-08-03T14:04:19.530-0500 I NETWORK [js] Updating host mongodb-local.computer:27018 state based on ismaster reply from ReplicaSet m. Self is primary: 1, primary is: mongodb-local.computer:27018, election ID: 7fffffff0000000000000002, ReplicaSet version: 1 2021-08-03T14:04:19.531-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongodb-local.computer:27019 (1 connections now open to mongodb-local.computer:27019 with a 10 second timeout) 2021-08-03T14:04:19.532-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Updating host mongodb-local.computer:27019 state based on ismaster reply from ReplicaSet m. Self is primary: 0, primary is: mongodb-local.computer:27018, election ID: 000000000000000000000000, ReplicaSet version: 1 2021-08-03T14:04:19.532-0500 F NETWORK [ReplicaSetMonitor-TaskExecutor-0] ReplicaSetMonitor m recieved error while monitoring mongodb-local.computer:27017: Location40356: connection pool: connect failed mongodb-local.computer:27017 : couldn't connect to server mongodb-local.computer:27017, connection attempt failed: SocketException: Error connecting to mongodb-local.computer:27017 (127.0.2.1:27017) :: caused by :: Connection refused(0 ms) 2021-08-03T14:04:19.532-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Received another failure for host mongodb-local.computer:27017 :: caused by :: Location40356: connection pool: connect failed mongodb-local.computer:27017 : couldn't connect to server mongodb-local.computer:27017, connection attempt failed: SocketException: Error connecting to mongodb-local.computer:27017 (127.0.2.1:27017) :: caused by :: Connection refused Implicit session: session { "id" : UUID("3e1a41f7-7886-4fdf-84fe-14e91606b386") } MongoDB server version: 4.0.25 MongoDB Enterprise m:PRIMARY>
Actual Results
see above
Additional Notes
if member on port 27017 is up, everything is fine with mongosh