情况描述,关了电脑,第二天查询数据,报错An error occurred while loading navigation: topology was destroyed

我的数据库连接代码如下:

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;

网上百度下,没什么合适的解释,大概理解一个意思,就是长时间没有请求,数据库断开了。
我又去找了 mongoose 重连数据库的方法,比较合理的是设置一个连接池,并自动重新连接,方法如下:
先定义一个 options 对象,如下:

const options = {  server: {auto_reconnect: true,poolSize: 10}
};`poolSize`是连接池最多可连接的数量,
`auto_reconnect`是自动重新连接,设置为 true,
然后在连接数据库的时候将 options 对象当作参数传入:
mongoose.connect('mongodb://localhost/test',options);

mongodb报错 An error occurred while loading navigation: topology was destroyed相关推荐

  1. 解决rdlc报错 An error occurred during local report processing

    转自VC错误:http://www.vcerror.com/?p=1597 问题描述: 从VS2005升级到2012或者2013后,原来做的报表,如果编辑过,而且不是转换成XML而是用编辑模式的话,会 ...

  2. IDEA启动报错Plugin Error Problems found loading plugins: Plugin “GlassFish Integration“ was not...

    IDEA启动报错Plugin Error的解决办法: Problems found loading plugins: Plugin "Persistence Frameworks Suppo ...

  3. Slowfast环境配置问题 | 安装PyAV报错An error occurred while installing package ‘conda-forge::olefile-0.46-pyh9f

    报错界面: Preparing transaction: done Verifying transaction: done Executing transaction: failed ERROR co ...

  4. win10使用markdownpad2报错 An error occurred with the HTML rendering component. This issue may be fixed b

    Win10下载安装完markdownpad2打开.md文件,报如下错误. An error occurred with the HTML rendering component. This issue ...

  5. tomcat 报错:Error occurred during initialization of VM

    Error occurred during initialization of VM Unable to load native library: Can't find dependent libra ...

  6. jmeter 非GUI模式下测试报错An error occurred: Unknown arg:

    D:\download\性能工具\JMeter\apache-jmeter-2.11\apache-jmeter-2.11\bin>jmeter -n -t E:\性能测试\jmeter scr ...

  7. nginx 开机启动报错An error occurred.

    问题描述: 配置nginx的开机启动后,nginx正常启动但是访问的网页访问不到错误 An error occurred. Sorry, the page you are looking for is ...

  8. NETCore项目报错 An error occurred while starting the application

    在发布到IIS的webApi项目中,运行时报出以上错误, 解决方法: 1.打开发布目录文件夹,找到web.config文件 2.打开web.config找到stdoutLogEnabled=" ...

  9. mybatis调用存储过程报错The error occurred while setting parameters

    最近项目用mybatis调用存储过程,在使用的过程中出现了一个错误:The error may involve com.stockcommission.dao.CommissionMapper.par ...

最新文章

  1. View 4桌面虚拟化炙手可热 但未熟透
  2. lepus监控oracle数据库_MySQL数据库监控软件lepus使用问题以及解决办法
  3. Ubuntu的网络设置
  4. Vue cli3.0创建Vue项目
  5. JavaSE——异常处理(异常简介、try-catch-finally、throws、throw)
  6. table中添加下拉框
  7. 全屏幕文本编辑器___Q10的设置:
  8. CentOS依赖包查找工具(https://centos.pkgs.org)
  9. 文字处理技术:最小布局
  10. 金融数据获取的api接口
  11. sketch(一)--安装和介绍
  12. index()函数和match()函数联合使用案例
  13. Gradle 插件 + ASM 实战 - 监控图片加载告警
  14. 东软、天健、金仕达、杭创、中联..HIS比较
  15. 吴恩达机器学习(十五)—— 应用实例:图片文字识别
  16. 服务器和普通电脑有什么区别?
  17. 9.3 开发经验和屁股的关系——《逆袭大学》连载
  18. tablayout如何设置字体大小,颜色等属性
  19. 一线城市软件测试工资——你拖后腿了吗
  20. 禁用计算机账户控制,禁用当前的账户【应对步骤】

热门文章

  1. 前端学习(2847):css鼠标样式
  2. 前端学习(2678):懂代码之表格BaseTable编辑操作
  3. 前端学习(2347):创建新页面和配置
  4. 前端学习(2056):初识vue.js
  5. git学习(8):windows系统下VI编辑器的基本使用
  6. shiro学习(21):动态添加验证规则1
  7. 第七十期:2019年度Java开发者路线图
  8. spring学习(37):注入list类型
  9. MAX535 单路13位DAC 模拟SPI驱动
  10. element-ui cascader 级联选择器 存最后一级id及回显