跳至内容

ElastiCache Redis connectivity error `redis.exceptions.ResponseError: MOVED 4720`

0

When I try connect to a redis instance I have from a Lambda I get the following error

redis.exceptions.ResponseError: MOVED 4720 test-0001-001.appdev-testev.nannan.apse2.cache.amazonaws.com:6379

I'm quite certain it has to do with some security group setup I have.

How I have the security groups setup when the error occurs

RedisSG (This is attached to the Redis instance): InboundRules: 6379 to SG RedisClientSG OutboundRules: 6379 to SG RedisClientSG

RedisCLinetSG (This is attached to the Lambda): OutboundRules: 6379 to SG RedisSG

The above security group configuration causes the MOVED 4720 error, However when I change the 6379 references to ALL TCP I can connect to the Redis instance from the lambda without any issue.

What ports do I actually have to limit the security groups to? and; Why do I have to have more ports open?

Additionally, of note my Redis cluster is working in Cluster Mode.

已提问 2 年前187 查看次数

2 回答
2

Hello,

To connect to your Redis instance from your Lambda, you need to open at least ports 6379 and 6380 in the Outbound Rules, and your Lambda must be in the same VPC as your Redis. Here’s a way to connect to it in Python:

import redis

redisClient = redis.StrictRedis (
    host = <ENDPOINT>,
    port = 6379,
    decode_responses = True,
    ssl = True
)

Make sure to include the ssl = True parameter.

And as you are in in Cluster Mode, you also need to open the ports 16379-16380 according to that doc

Hope it helps 😊

专家

已回答 2 年前

0

So turns out it is something to do with the ports but, also to do with the actual implementation of the redis connector and how it connects to different nodes.

Best explanation I found on fixing this problem was from here https://www.dragonflydb.io/error-solutions/redis-exceptions-responseerror-moved.

Will let you know which ports this actually connects on and uses.

已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。