Mongoose Trying to open unclosed connection

前端 未结 6 430
离开以前
离开以前 2020-12-24 05:38

This is a simplified version of the problem, but basically I\'m trying to open 2 mongodb connections with mongoose and it\'s giving me \"Trying to open unclosed connection.\

6条回答
  •  囚心锁ツ
    2020-12-24 06:29

    You are attempting to open the default connection ( which is not yet closed ) a 2nd time.

    do the following instead

    var db = require('mongoose'); //note only one 'require' needed.
    var connectionToDb1 = db.createConnection('my.db1.ip.address', 'my-db1');
    var connectionToDb2 = db.createConnection('my.db2.ip.address', 'my-db2');
    

提交回复
热议问题