thinkjs / thinkjs

Use full ES2015+ features to develop Node.js applications, Support TypeScript.
https://thinkjs.org/
MIT License
5.31k stars 616 forks source link

mongodb数据连接丢失 ,问题还是没有解决 #587

Open murongyuange opened 7 years ago

murongyuange commented 7 years ago

我用了2个数据库连接(A库和B库,分别在不同的模块下),其中A为默认common的连接且用它来session,服务启动不长时间,A的连接就丢失了,B库连接正常,但是session却能正常读取!就是A的连接(let mess = think.model("mess",think.config("db",undefined,'common'),"common");)怎么也拿不到连接了! B库也使用同样的方法(let wnl = think.model("wnl",think.config("db",undefined,'gr'),"gr"); //)却正常. 当A库的连接直接使用B库的db.js时,A,B二库连接均会丢失

'use strict';
/**A库连接 src/common/下
 * db config
 * @type {Object}
 */
export default {
  //此配是为了session存到mongodb中!
  type: 'mongo',
  host: '192.168.0.3',
  port: '27017',
  database: 'food', // database name
  user: '',
  password: '',
  prefix: 't_',
  encoding: 'utf8',
  nums_per_page: 10,
  log_connect: true,
  cache: {
    on: true,
    type: '',
    timeout: 3600
  }
};
/////////////////////////////////////////////////
'use strict';
/**B库连接 src/gr/下
 * db config
 * @type {Object}
 */
export default {
  //
  type: 'mongo',
  host: '192.168.0.3',
  port: '27017',
  database: 'gren', // database name
  user: '',
  password: '',
  prefix: 't_',
  encoding: 'utf8',
  nums_per_page: 10,
  log_connect: true,
  cache: {
    on: true,
    type: '',
    timeout: 3600
  }
};
/////////////////////////////////////////

以上2个db.js均不在当前模块下,我在src/cn/模块下调用这2个配置语句为: A:let mess = think.model("mess",think.config("db",undefined,'common'),"common"); B:let wnl = think.model("wnl",think.config("db",undefined,'gr'),"gr")

请问,如何是好? 想过许多法子,总是无效.真的要崩溃了,,,,请救命

welefen commented 7 years ago

有具体的报错信息么?

murongyuange commented 7 years ago

thinkjs没有报错信息,只是提示页面超时