Hey,
I’m using the mongodb node driver (version 3.0.6) in my server and I am having trouble with a specific use case problem that I wish to get the answer from you.
I have a replica set of 6 mongos which are sectioned to: 1 master 5 secondaries (which 3 of them are passives).
I have a node service with 4 instances of this service that connects to the replica set. Each instance is connected to a part of the replica set and not the whole set (because of a need my app requires to divided some of the DBs), the division is: I have a “core” set which includes the master and the 2 secondaries (which are not passives).
The first instance includes only the core set - and for the example shall be called “Core Instance”. The others are connected to the core set and only one of the remaining passives db (every secondary is used by an instance of my node service) - and for the example shall be called “External instance”.
I noticed that when one of the “External instances” is shutting down (because the server is shut down) the other “External instances” are having a connection error for several minutes (and after few minutes the service is working good again).
The error that is shown in the “External instances” while the shutdown is happening is:
At the docker service:
"error: MongoNetworkError: Connection 46 to {server-name} timed out
at Socket<anonymous> .../node-modules/mongodb-core/lib/connection/connection-js:258:7).
...".
At the localhost:
"Error: read ECONNRESET at tcp. on StreamRead (internal-stream_base_commons.js:167:27)".
I don’t understand why when one the “External instances” is failing the other instances are having trouble in the connection.
In my opinion, it is because of the replica set connection in the MongoClient.connect URI (is written as the documentation mentiones:
“mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?replicaSet=myRepl”), that it is ignoring the host list and connected to the whole replica set (or that it is working correctly but I didn’t understand the host list meaning).
My mongo version is 3.6.5 . The mongodb npm package is 3.0.10 .
*Maybe worth to mention that we are using the oplog.