Reputation: 176
We are using nodejs and mongoose on our production server. The mongo logfiles are full with connects/disconnects. They all happens every 30 seconds.
Wed Jan 15 10:08:52.280 [initandlisten] connection accepted from 10.3.138.16:50946 #1089677 (137 connections now open)
Wed Jan 15 10:09:22.291 [conn1089677] end connection 10.3.138.16:50946 (140 connections now open)
Does anyone have a clue about this?
Upvotes: 0
Views: 465
Reputation: 203359
This is what the fine manual states:
A note about
keepAlive
For long running applictions it is often prudent to enable
keepAlive
. Without it, after some period of time you may start to see"connection closed"
errors for what seems like no reason. If so, after reading this, you may decide to enablekeepAlive
:
options.server.socketOptions = options.replset.socketOptions = { keepAlive: 1 };
mongoose.connect(uri, options);
Upvotes: 1