ioredis在从aws elasticache redis“get”时不执行任何操作

i7uaboj4  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(444)

我正在ecs上托管的nodejs容器中运行以下代码。使用redis在本地运行非常好。在aws中,它看起来是连接的(如果我使用了无效的地址,它会在连接时出错,所以我假设它是连接的)。当我跑的时候 redis.get( 什么都没发生。我已启用ioredis调试,尝试获取时收到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中。我能做些什么来解决这个问题?
我调出的更新 ioredisredis 但事情还是发生了,娜达。。。

uttx8gqw

uttx8gqw1#

修好了!我不知道我(aws新手)在传输过程中为加密配置了elasticache。一旦我设置了auth令牌并将其用于 ioredis 真管用!我又做生意了!

相关问题