■ 服务器运行一段时间(超过10小时后),就会报错:
MongoError: connection 1263 to 123.123.123.123:3717 timed out at Function.MongoError.create (/workdir/node_modules/.2.0.12@mongodb-core/lib/error.js:29:11) at Socket.<anonymous> (/workdir/node_modules/.2.0.12@mongodb-core/lib/connection/connection.js:173:20) at Socket.g (events.js:291:16) at emitNone (events.js:86:13) at Socket.emit (events.js:185:7) at Socket._onTimeout (net.js:339:8) at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5)
■ 重启后就正常了,正常一段时间后,有会报听同样的错。
■ 数据库连接代码如下:
var mongoose = require(‘mongoose’); mongoose.connect(config.db,function (err) { if (err) { logger.error(‘connect to %s error: ‘, config.db, err.message); process.exit(1); } }); require(’./user’); exports.User = mongoose.model(‘User’);