请教:为什么我在用mongodb时,在 db.open() 这个时候,有时候会报错:connection closed
代码如下:
var poolModule = require(‘generic-pool’);
exports.dbpool = pool = poolModule.Pool({
name : ‘mongo’,
create : function(callback) {
var server_options = {
auto_reconnect: true
},
db_options = {
native_parser: true,
strict: false,
safe: false
};
var mongo = require(“mongodb”);
var mongoServer = new mongo.Server(‘10.0.0.125’, 27017, server_options);
dbName = ‘test’;
db = new mongo.Db(dbName, mongoServer, db_options);
db.open(function(err, client){
if(err){
console.log('Error open db: '+err);
return false;
}
if(callback) callback(err, client);
});
},
destroy : function(client) {
client.close();
},
max : 50,
idleTimeoutMillis :30000,
log : false
});
今天把这个genneric-pool与mongodb的用法改装成这样,就出现了,以前不是这样的,但以前也是有别的问题的。。。
所以出现这个问题后,我就不知道该如何处理了!
居然还有这样的错误: { [Error: accept EMFILE] code: ‘EMFILE’, errno: ‘EMFILE’, syscall: ‘accept’ }
该如何是好啊!???