繁体   English   中英

通过 NestJS 缓存模块的 Redis ElastiCache 连接错误

[英]Redis ElastiCache connection error through NestJS Cache Module

我正在尝试将 CacheModule 连接到 AWS ElastiCache 上的 Redis 服务器,但没有成功。

我通过 EC2 本身内的 redis-cli 建立了连接,它工作正常,但 NestJS 没有连接。

CacheModule.register<RedisClientOptions>({
      isGlobal: true,
      store: redisStore,
      socket: {
        host: 'master.my-server.use1.cache.amazonaws.com',
        port: 6379,
        tls: true,
      },
      password: 'my-password',
    }),

PM2/控制台错误:

node:events:505
PM2        |       throw er; // Unhandled 'error' event
PM2        |       ^
PM2        |
PM2        | Error: connect ECONNREFUSED 127.0.0.1:6379
PM2        |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
PM2        | Emitted 'error' event on RedisClient instance at:
PM2        |     at RedisClient.on_error (/home/ec2-user/quark-be/node_modules/cache-manager-redis-store/node_modules/redis/index.js:342:14)
PM2        |     at Socket.<anonymous> (/home/ec2-user/quark-be/node_modules/cache-manager-redis-store/node_modules/redis/index.js:223:14)
PM2        |     at Socket.emit (node:events:527:28)
PM2        |     at emitErrorNT (node:internal/streams/destroy:157:8)
PM2        |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
PM2        |     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
PM2        |   errno: -111,
PM2        |   code: 'ECONNREFUSED',
PM2        |   syscall: 'connect',
PM2        |   address: '127.0.0.1',
PM2        |   port: 6379
PM2        | }

文档中有错误。 该文档考虑到 cache-manager-redis-store 支持 redis v4,因此导致读者相信他们在未读取时设置了主机和端口: https ://github.com/nestjs/docs.nestjs .com/pull/2333

暂无
暂无

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

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