1

I have a node application used with express framework. This application runs smoothly. But suddenly, after some point of time, it starts to give error as

"Error: no open connections at Db._executeQueryCommand"

From the description of above error, I am just getting that, node application might not be able to make connection to Database.

But, in spite of getting this error, some of the pages, that are rendered by node application are able to run.

One thing I will like to add is, there's no certain page, in which am getting this error, I mean to say that, suppose first time, I get this error in "/foo" page, and not in "/foo1" and "/foo2".

But, suppose, when I randomly refresh pages, the page which loaded with error before, that is "/foo" might not give error, and pages loading successfully before,that is "/foo1" and "/foo2", might give error.

Number of concurrent users for node application might not be ever more, approximately, they would be around 450.

Details: 1. Node Version : v0.10.29 2. Express Version : 4.9.0 3. MongoDB Version : 2.4.10 4. OS Linux

I searched for many solutions, but did not find a strong cause or even solution for the same.

Any help will be greatly appreciated.

gehlotparesh
  • 142
  • 3
  • 13

1 Answers1

0

Check this issue, it suggests to use {auto_reconnect: true} for mongodb connection.

Also you can try following

// Connect to mongodb
var connect = function () {
  var options = { server: { socketOptions: { keepAlive: 1 } } };
  mongoose.connect('mongodb://localhost/db1', options);
};

connect();

mongoose.connection.on('error', console.log);
mongoose.connection.on('disconnected', connect);
Kiran Pagar
  • 1,005
  • 15
  • 21