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
질문됨 5달 전246회 조회
1개 답변
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
전문가
답변함 5달 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠