ElastiCache Reids connection fail from ECS.

0

Redis Configuration information
Deploy Option : Serverless
Secure : AWS KMS, Encryption in transit enabled, No access control
Secure Group : 6379 = 0.0.0.0/0
AZ : ap-northeast-2a, ap-northeast-2b, ap-northeast-2c Public subnet
(VPC and Subnet were created custom.)

ECS - Task Configuration information
Type : AWS Rargate
OS : Linux/X86_64
Roles : ecsTaskExecutionRole, ecsTaskExecutinRole
Container Port: 3000
CPU/RAM : 0.25 / 0.5

ECS - Service Configuration information
Capacity provider strategy : Fargate / 0 / 1 / Latest
Deploy : Service, 1 Task
Subnet: Private Subnet
Network : Public IP ON
Secure Group : 80 = 0.0.0.0/0, 6378 = 0.0.0.0/0

Settings other than the above are default settings. NAT Gateway is set in the VPC Private Subnet, and all other ECS deployed in the Private Subnet are serviced over the Internet.

I confirmed that Redis was connected normally to the Private EC2 instance using the command below.

$ redis-cli -h [redis name]serverless.apn2.cache.amazonaws.com --tls -p 6379

Redis connection test code (node.js)

import express from 'express';
import { createClient } from 'redis';

const app = express();
const port = 3000;
const redisConf = {
	url: 'redis://[redis name].serverless.apn2.cache.amazonaws.com:6379',
	socket: {
		tls: true,
	},
};
const redis = await createClient(redisConf);
setInterval(() => {
	console.log('redis : ' + JSON.stringify(redis));
}, 10000);

app.get('/', async (req, res) => {
	console.log('redis : ' + JSON.stringify(redis));
	res.send('Hello World!');
});

app.listen(port, () => {
	console.log(`Example app listening at ${port}`);
});

how to properly connect to Redis?

kp
asked 4 months ago236 views
1 Answer
0

Hi,

I am not sure if this's the case, but I met before rediss:// as declaration that it will be TLS connection (I see you defined it differently below)

To connect to a different host or port, use a connection string in the format redis[s]://[[username][:password]@][host][:port][/db-number]:

profile picture
EXPERT
answered 4 months ago
  • A basic part was overlooked. However, even if the "rediss" protocol is applied, the connection still fails. Is there anything else I should check?

  • As an additional note, there were no user settings (ID, PW) when configuring serverless redis.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions