简体   繁体   English

如何配置nest/Bull redis连接

[英]how to configure nest/Bull redis connection

I am using BullModule in nest.js.我在nest.js 中使用BullModule。

when I connect to a local redis it works:当我连接到本地 redis 时,它可以工作:

const REDIS = {
  host: 'localhost', 
};

@Module({
  imports: [
    TaskTypesModule,
    TasksModule,
    ScheduleModule.forRoot(),
    BullModule.forRoot({
      // @ts-ignore
      redis: REDIS,
    }),
  ],
  controllers: [AppController],
  providers: [AppService, PrismaService],
})
export class AppModule {}

But when I connect to a remote system但是当我连接到远程系统时

const REDIS = {
  host: process.env.REDIS_ENDPOINT,
  port: process.env.REDIS_PORT,
  password: process.env.REDIS_PASSWORD,
};

with env file带有环境文件

REDIS_USERNAME=default
REDIS_PASSWORD=p----------------------S
REDIS_ENDPOINT=redis-1xxxxx4.c261.us-east-1-4.ec2.cloud.redislabs.com
REDIS_PORT=1xxxxx4

it doesn't write to the redis queue;它不会写入 redis 队列; by way of comparison, I can connect via redisight:作为比较,我可以通过 redisight 进行连接:

enter image description here在此处输入图像描述

So - bottom line - how to configure the redis node for a remote connection in Bull?那么 - 底线 - 如何在 Bull 中为远程连接配置 redis 节点?

Maybe the env file hasn't been loaded yet.可能尚未加载 env 文件。 You can try adding import 'dotenv/config' at the top of this file.您可以尝试在此文件顶部添加import 'dotenv/config'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM