Mongo连接配置
mongoose.connect(mongo.uri, {
socketTimeoutMS: 30000,
reconnectTries: 30000,
connectTimeoutMS: 30000,
keepAlive: 1,
useNewUrlParser: true,
});我正在尝试使用播种器插入数据,但我的数据非常大。我的数据文件大小是70mb。
mongo连接URL是我的服务器mongo URL。
UnhandledPromiseRejectionWarning: MongoNetworkError: connection 6 to [connection_url] timed out
at TLSSocket.<anonymous> (/usr/src/node_modules/mongodb-core/lib/connection/connection.js:259:7)
at Object.onceWrapper (events.js:288:20)
at TLSSocket.emit (events.js:200:13)
at TLSSocket.Socket._onTimeout (net.js:432:8)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
(node:71) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:71) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.如果任何人对此有任何想法,请帮助。任何帮助都将不胜感激。
发布于 2019-07-12 15:27:37
我找到了这个错误的解决方案。这不是一个完美的解决方案,但它对我来说是有效的。我已经将我的种子数据分成多个块,并逐个块地插入。
const _ = require('lodash');
_.chunk([large Data Object], 500);500 =您希望在一个区块中包含的数据数量
希望它也能为你工作!
https://stackoverflow.com/questions/56972896
复制相似问题