I am running the following code in a nodejs container hosted on ECS. This runs great locally using redis. In AWS, it appears to connect (if I use an invalid address it errors on connection so I'm assuming it's connected). When I run redis.get(
nothing happens. I've enabled debugging for ioredis and I get 1 message when I attempt the get:
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....
Here's the code
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());
}
};
I've confirmed security groups, ElastiCache is in the same VPC as my ECS container. What can I do to troubleshoot this?
UPDATE
I swapped out ioredis
with redis
and it still happens, nada...
Fixed it! I wasn't aware I (newb to AWS) configured ElastiCache for Encryption in Transit. Once I set the auth token and used that with ioredis
it works! I'm back in business!