Node.js MongoServerSelectionError:连接在超时时超时。\u onTimeout

Node.js MongoServerSelectionError:连接在超时时超时。\u onTimeout,node.js,mongodb,express,timeout,Node.js,Mongodb,Express,Timeout,错误 MongoServerSelectionError:连接超时 超时。_onTimeout(D:\NodeJS\SearchEngine\node\u modules\mongodb\lib\core\sdam\topology.js:438:30) 在listOnTimeout(internal/timers.js:554:17) 在processTimers(internal/timers.js:497:7){ 原因:拓扑学描述{ 类型:“未知”, setName:null, maxSe

错误

MongoServerSelectionError:连接超时
超时。_onTimeout(D:\NodeJS\SearchEngine\node\u modules\mongodb\lib\core\sdam\topology.js:438:30)
在listOnTimeout(internal/timers.js:554:17)
在processTimers(internal/timers.js:497:7){
原因:拓扑学描述{
类型:“未知”,
setName:null,
maxSetVersion:null,
maxElectionId:null,
服务器:映射{'localhost:27017'=>[ServerDescription]},
陈腐:错,
是的,
兼容性错误:null,
logicalSessionTimeoutMinutes:空,
心跳频率:10000,
localThresholdMS:15,
commonWireVersion:空
}
}
代码

试试看{
const client=wait MongoClient.connect(connection.url,usermail.config\u connection)
var头=[];
const db=client.db(connection.name);
log(header\u data.return\u call\u back\u header(header\u data.header\u id\u info.ecommerce));
//res.render('index.ejs',{title:header});
console.log(头文件);
}捕获(错误){
控制台错误(错误)
}
配置连接

const-config\u连接={
连接超时:5000,
socketTimeoutMS:5000,
useUnifiedTopology:正确,
useNewUrlParser:true,
服务器选择超时:5000,
}
网址


如果删除
serverSelectionTimeoutMS:5000
,是否会有任何变化?它会限制服务器加载数据的时间。否则连接需要很多时间,3分钟后显示相同的错误。我从MongoDB文档中获取此参考
url:'mongodb://localhost:27017/searchEngine', name:'searchEngine',