-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Mongoose not closing connections #3863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you able to connect using the mongo shell? Does the connection stay open? |
@vkarpov15 yes. It works perfectly from mongo shell. I'm starting to suspect linux configurations... in case you can say for sure it's not with mongoose or mongodb driver? |
Anyone can help here? Another finding we had is that connections are less likely to rise when we remove the socketTimeout and connectionTimeout and keepAlive settings. Not sure why... |
Which version of mongoose? Also try reading through the thread on #3634 and https://jira.mongodb.org/browse/NODE-622, this looks like a similar issue |
We use the latest v4.4.2 Right now we removed all mongoose settings except I don't know if this is recommended to do things like that but we didn't find any other option. |
There's a lot of tips in the issues I referenced in #3863 (comment) . Typically these issues are because of the network, and often the solution is "tune socketTimeoutMS to the right value". You may also want to watch the 'joined' and 'left' events referenced in https://jira.mongodb.org/browse/NODE-622 and turn on debug mode for repl sets as described here: #3634 (comment) to get more insight into what's going on. |
@vkarpov15 we tried tuning the socketTimeout. We set larger and shorter values... nothing helped. When we removed it, things started behaving good. I wonder if you have an explanation to that. |
AFAIK socketTimeoutMS=0 means use the OS' socket timeout, so if that works for you go for it. I personally don't bother setting socketTImeoutMS ever. Some more info: http://mongodb.github.io/node-mongodb-native/2.0/tutorials/connection_failures/ . |
@vkarpov15 perfect thanks! |
I'm using mongoose to connect to my MongoDB server on production.
I've set tcp_keepalive_time to 120:
The problem is the connections keep opening to the server but never closing.
Btw, connections are only opening to Primary. On Secondary I don't see too many open connections.
The text was updated successfully, but these errors were encountered: