I have a simple replica set with 3 members
Ouput of rs.status()
{
...,
"members" : [
{
"_id": 1,
"name": "localhost:27021",
"stateStr": "PRIMARY",
},
{
"_id": 2,
"name": "localhost:27022",
"stateStr": "SECONDARY",
},
{
"_id": 3,
"name": "localhost:27023",
"stateStr": "SECONDARY",
}
]
}
I removed one member
rs.remove("localhost:27023")
Now rs.status()
{
...,
"members" : [
{
"_id": 1,
"name": "localhost:27021",
"stateStr": "PRIMARY",
},
{
"_id": 2,
"name": "localhost:27022",
"stateStr": "SECONDARY",
},
]
}
Now I used a mongodb connection URL with removed instance. It connected to replica set members successfully!!
var url = 'mongodb://localhost:27023/myproject?replicaSet=rs0';
MongoClient.connect(url, function(err, db) {
console.log("Connected correctly to server");
db.close();
});
I could see the connection was established with replica set members(localhost:27022 and localhost:27023)
2019-04-17T18:59:04.727+0900 I NETWORK [thread1] connection accepted from 127.0.0.1:53284 #6 (3 connections now open)
2019-04-17T18:59:04.727+0900 I NETWORK [conn6] received client metadata from 127.0.0.1:53284 conn6: { driver: { name: "nodejs", version: "3.2.3" }, os: { type: "Linux", name: "linux", architecture: "x64", version: "4.15.0-47-generic" }, platform: "Node.js v10.15.0, LE, mongodb-core: 3.2.3" }
2019-04-17T18:59:04.736+0900 I - [conn6] end connection 127.0.0.1:53284 (3 connections now open)
2019-04-17T18:59:35.334+0900 I ASIO [NetworkInterfaceASIO-RS-0] Ending idle connection to host localhost:27021 because the pool meets constraints; 1 connections to that host remain open
Can someone explain this? Connecting to replica set members through a removed member. Could not find any explanation in any docs.