I found it in some documentation:
For long running applications, it is often prudent to enable “keepAlive” with a number of milliseconds. Without it, after some period of time you may start to see “connection closed” errors for what seems like no reason.
Check if this helps. When you connect to mongoDB you can pass socket options to it. I am from node background we use following options to keep it alive.
server: {
socketOptions: {
keepAlive: 100,
connectTimeoutMS: 30000
}
}
Hope this helps!!