MongoNetworkError:与ercluster-shard-00-01-8xhj2.mongodb.net:27017的连接5超时

时间:2019-06-14 11:42:55

标签: node.js database mongodb mongoose connection-timeout

我正在使用react和nodejs。当我向mongodb发送查询时,一段时间(2-3分钟)后,我收到此错误(MongoNetworkError超时)。我正在使用在mongo地图集上创建的集群。

我试图在mongo地图集上创建新帐户和集群,设置新的mongo uri,但是问题是相同的。

console.log("mongoUri:", config.mongoUri);
const options = {
  useNewUrlParser: true
  // keepAlive: 300000,
  // connectTimeoutMS: 30000
};
mongoose.connect(config.mongoUri, options, err => {
  console.log("error occured", err);
});
console.log("mongoose connection:", mongoose.connection.readyState);
mongoose.connection.readyState;

error occured { MongoNetworkError: connection 4 to etcluster-shard-00-01-u7zep.mongodb.net:27017 timed
out
    at TLSSocket.<anonymous> (C:\Users\Petar\Documents\GitHub\eliteranks\elite-ranks-back\node_modules\mongoose\node_modules\mongodb-core\lib\connection\connection.js:335:7)
    at Object.onceWrapper (events.js:273:13)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket.Socket._onTimeout (net.js:449:8)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
  name: 'MongoNetworkError',
  errorLabels: [ 'TransientTransactionError' ],
  [Symbol(mongoErrorContextSymbol)]: {} }
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
    at TLSSocket.<anonymous> (C:\Users\Petar\Documents\GitHub\eliteranks\elite-ranks-back\node_modules\mongoose\node_modules\mongodb-core\lib\connection\connection.js:321:10)
    at Object.onceWrapper (events.js:273:13)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
[nodemon] app crashed - waiting for file changes before starting...

0 个答案:

没有答案