search

Home  >  Q&A  >  body text

node.js - 【mongodb · mongoose】错误 "Topology was destroyed" 怎么解决?

怪我咯怪我咯2873 days ago815

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 16:12:13

    Solved, the problem is that the database is disconnected and needs to be reconnected. I introduced it in the following blog:
    Solution

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 16:12:13

    I have never encountered a similar error, but I searched stackoverflow and found posts with similar problems:

    http://stackoverflow.com/ques...

    The problem is probably related to the instability of the network, so one method in the post is to modify the connect options:

    var options = {
    server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
    replset: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } } }
    };
    mongoose.connect(secrets.db, options);

    For reference.

    Have a great weekend!


    Love MongoDB! Have Fun!


    Save RP

    reply
    0
  • Cancelreply