I am running containers on ECS Fargate and everything is working as expected but there is one issue. When I have this redis code running in my server side, the server container is failing to reach a steady state and failing.
And when I expand the api container its showing Error Code 137
const REDIS_ENDPOINT = process.env.REDIS_ENDPOINT;
const pubClient = createClient({
url: REDIS_ENDPOINT,
});
const subClient = pubClient.duplicate();
await Promise.all([pubClient.connect(), subClient.connect()]);
Plus there are no logs given by the server container in my cloudwatch. All other containers are working as expected such as client, nginx, mongo and redis.
After doing some more research, I read that its due to the memory and I tried increasing that to 15 gb in my ECS task definition which is more that enough (Just for checking). I am sure its not this issue since everything is working with 6 gb when I don't have the above mentioned code.
My elasticache redis endpoint is also in the correct format redis://mycompany-534sdf.serverless.use1.cache.amazonaws.com:6379
I have port 6379 open in my security group
Everything is working as expected locally when I am using docker compose
Really need some help here. I am pulling my hair out as I am typing this.
I was using Elasticache Redis serverless and found out that it does not support pub sub capability.
You have to create your own cluster and everything will work fine.