mongodb报错 An error occurred while loading navigation: topology was destroyed
情况描述,关了电脑,第二天查询数据,报错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相关推荐
- 解决rdlc报错 An error occurred during local report processing
转自VC错误:http://www.vcerror.com/?p=1597 问题描述: 从VS2005升级到2012或者2013后,原来做的报表,如果编辑过,而且不是转换成XML而是用编辑模式的话,会 ...
- IDEA启动报错Plugin Error Problems found loading plugins: Plugin “GlassFish Integration“ was not...
IDEA启动报错Plugin Error的解决办法: Problems found loading plugins: Plugin "Persistence Frameworks Suppo ...
- 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 ...
- 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 ...
- tomcat 报错:Error occurred during initialization of VM
Error occurred during initialization of VM Unable to load native library: Can't find dependent libra ...
- 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 ...
- nginx 开机启动报错An error occurred.
问题描述: 配置nginx的开机启动后,nginx正常启动但是访问的网页访问不到错误 An error occurred. Sorry, the page you are looking for is ...
- NETCore项目报错 An error occurred while starting the application
在发布到IIS的webApi项目中,运行时报出以上错误, 解决方法: 1.打开发布目录文件夹,找到web.config文件 2.打开web.config找到stdoutLogEnabled=" ...
- mybatis调用存储过程报错The error occurred while setting parameters
最近项目用mybatis调用存储过程,在使用的过程中出现了一个错误:The error may involve com.stockcommission.dao.CommissionMapper.par ...
最新文章
- View 4桌面虚拟化炙手可热 但未熟透
- lepus监控oracle数据库_MySQL数据库监控软件lepus使用问题以及解决办法
- Ubuntu的网络设置
- Vue cli3.0创建Vue项目
- JavaSE——异常处理(异常简介、try-catch-finally、throws、throw)
- table中添加下拉框
- 全屏幕文本编辑器___Q10的设置:
- CentOS依赖包查找工具(https://centos.pkgs.org)
- 文字处理技术:最小布局
- 金融数据获取的api接口
- sketch(一)--安装和介绍
- index()函数和match()函数联合使用案例
- Gradle 插件 + ASM 实战 - 监控图片加载告警
- 东软、天健、金仕达、杭创、中联..HIS比较
- 吴恩达机器学习(十五)—— 应用实例:图片文字识别
- 服务器和普通电脑有什么区别?
- 9.3 开发经验和屁股的关系——《逆袭大学》连载
- tablayout如何设置字体大小,颜色等属性
- 一线城市软件测试工资——你拖后腿了吗
- 禁用计算机账户控制,禁用当前的账户【应对步骤】