我将 Nestjs 与 Bull 队列一起使用。我的工人有一个非常足智多谋的任务,通常完成 5 分钟左右。并且需要大量内存。
我的 Mongo 和 Nestjs 微服务正在使用带有 docker-compose
驱动程序 the example you might see here 的 network: bridge
。
我通过 MongooseModule.forRoot
连接到 Mongo,使用以下选项:
export const mongoOptionsConfig: MongooseModuleOptions = {
useNewUrlParser: true,
useFindAndModify: false,
useCreateIndex: true,
useUnifiedTopology: true,
poolSize: 10,
socketTimeoutMS: 1000 * 60 * 60,
connectTimeoutMS: 1000 * 60 * 60
}
有时,我的员工会收到 Mongo 的以下连接错误:
[Nest] 1 - 04/26/2021, 1:27:07 PM [AppWorker] AppWorker: MongooseServerSelectionError: Server selection timed out after 30000 ms +54391ms
或
[Nest] 1 - 04/26/2021, 1:15:31 PM [AppWorker] AppWorker: Error: timeout of 30000ms exceeded +31730ms
通常在 insertMany
之前/之中,具有 60k 对象数组。
但是,如果我的连接设置允许创建大约一个小时的连接,这怎么可能?