我目前遇到了一个问题,我已经尝试解决一个多星期了,但毫无进展。我希望你能指出我正确的方向。
我正在构建的项目是一个NestJS应用程序,它连接到一些 API。在内部,它使用bullmq作为消息队列,它本身使用ioredis连接到 redis 数据库。docker-compose up我已经通过以下配置连接了我自己编写的服务器组件以及redis(使用docker) :
version: '3'
services:
server:
image: myserver:1.4.0
container_name: myserver
depends_on:
- db
ports:
- 3001:3000
environment:
- REDIS_HOST=redis
db:
image: redis:6.0.8
container_name: redis
ports:
- 6379:6379
Run Code Online (Sandbox Code Playgroud)
我的服务器组件的问题是,它尝试使用以下代码连接到给定 REDIS_HOST 端口 6379 下的 redis 实例:
readonly connection = new Redis(
+(process.env.REDIS_PORT ?? this.configService.get('redis_port')),
process.env.REDIS_HOST ?? this.configService.get('redis_host'),
); …Run Code Online (Sandbox Code Playgroud)