My Node.js application has a MongoDB connection, which when running on localhost connects immediately. When I'm running it on a shared hosting server, it takes at least 10 sec to connect every time. What I have tried so far, but did not help: changing connection parameters as follows:
useNewUrlParser: true,
useUnifiedTopology: true,
connectTimeoutMS:3600000,
keepAlive:3600000,
socketTimeoutMS:3600000
Also tried using MongoHeartbeat to keep the connection alive, but it did not help.