I am facing a really weird scenario, the initial connection to mongoDb takes around 15 seconds. My current setup is the following:
Upon restarting nodemon the initial signin POST takes around 15 seconds
POST /api/v1/signin 200 14707ms - 56b
other POST to the same route without restarting the server is relatively fast:
POST /api/v1/signin 200 76ms - 56b
the reason why this bothers me is that because this project is still in development, nodemon tends to restart a lot and testing is being a pain.
I am using the following node modules which are related to db and authentication:
this is the way i am connecting to mongo:
var mongoUrl = "mongodb://devmachine.local:27017/project";
mongoose.connect(mongoUrl, {auto_reconnect: true});
any help would be highly appreciated.
Thanks
If you have created a user and are having trouble authenticating, try the following: Check that you are using the correct username and password for your database user, and that you are connecting to the correct database deployment. Check that you are specifying the correct authSource database in your connection string.
Sharded Cluster Connection Poolingmongos routers have connection pools for each node in the cluster.
useNewUrlParser : The underlying MongoDB driver has deprecated their current connection string parser. Because this is a major change, they added the useNewUrlParser flag to allow users to fall back to the old parser if they find a bug in the new parser.
The connection pool is on a per-mongod/mongos basis, so when connecting to a 3-member replica there will be three connection pools (one per mongod), each with a maxPoolSize of 1.
Replace the hostname with IP
From: var mongoUrl = "mongodb://devmachine.local:27017/project";
To: var mongoUrl = "mongodb://127.0.0.1:27017/project";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With