当来自 AWS ElastiCache Redis 的 'get' 时,nodejs 中的 ioredis 不执行任何操作

ioredis in nodejs does nothing when 'get' from AWS ElastiCache Redis

我正在 运行在 ECS 上托管的 nodejs 容器中编写以下代码。这 运行 在本地使用 redis 非常有用。在 AWS 中,它似乎已连接(如果我使用无效地址,它会在连接时出错,所以我假设它已连接)。当我 运行 redis.get( 没有任何反应。我为 ioredis 启用了调试,当我尝试 get:

时收到 1 条消息
2020-04-17T22:56:10.701Z ioredis:redis status[replica.virtual-happy-hour-redis.fnt3zc.usw2.cache.amazonaws.com:6379]: [empty] -> connecting
2020-04-17T22:56:11.042Z ioredis:redis status[10.200.0.37:6379]: connecting -> connect
2020-04-17T22:56:11.045Z ioredis:redis write command[10.200.0.37:6379]: 0 -> info([])
2020-04-17T23:02:02.627Z ioredis:redis queue command[10.200.0.37:6379]: 0 -> get([ 'friday' ])
# suspense is killing me....

这是代码

var Redis = require('ioredis'),

console.log('cache connecting to', CONFIG.CACHE_URL);
var redis = new Redis(CONFIG.CACHE_URL);
console.log('cache connected');

const getRoom = (roomName, callback) => {
  let room;
  console.log('getRoom', roomName); // this logs as expected, nothing after this does
  try {
    redis.get(roomName, (err, result) => {
      if (err) {
        console.log('get cache error', err);
      } else {
        if (result) {
          console.log('cache result', result);
          room = JSON.parse(result);
        } else {
          console.log('no cache', roomName);
          room = defaultRoom(roomName);
          redis.set(roomName, JSON.stringify(room));
        }
      }
      if (callback) callback(room);
      console.log('getRoom done');
    });
  } catch (ex) {
    console.log('getRoom error', ex.toString());
  }
};

我已确认安全组,ElastiCache 与我的 ECS 容器位于同一 VPC 中。我该怎么做才能解决这个问题?

更新 我用 redis 换掉了 ioredis 但它仍然发生,nada...

已修复!我不知道我(AWS 的新手)为传输中的加密配置了 ElastiCache。一旦我设置了身份验证令牌并将其与 ioredis 一起使用,它就可以工作了!我回来了!