简体   繁体   English

无法连接到 AWS ElastiCache 表单 python 客户端

[英]Unable to connect to AWS ElastiCache form python client

I have an AWS ElastiCache instance of 2 replicated nodes (cluster-mode disabled).我有 2 个复制节点的 AWS ElastiCache 实例(禁用集群模式)。 I am able to connect through my java client using redisson (a service running in the same cluster).我可以使用 redisson(在同一集群中运行的服务)通过我的 java 客户端进行连接。 However, when I'm using the python redis client, it does not seem to connect.但是,当我使用 python redis 客户端时,它似乎无法连接。 Or it seems to connect but doesn't subscribe.或者它似乎连接但不订阅。 I don't see any errors for connection, but when I subscribe to a pub/sub topic I don't get any acknowledgment as well.我没有看到任何连接错误,但是当我订阅发布/订阅主题时,我也没有收到任何确认。 Not even the first message which returns 1 for the successful subscription.甚至没有为成功订阅返回1的第一条消息。 Not sure what I'm doing wrong.不知道我做错了什么。 Also it works if I'm connecting to a local redis instance.如果我连接到本地 redis 实例,它也可以工作。 Below is the code:下面是代码:

self.redis_conn = redis.Redis(host=os.environ.get(host), port=6379, password=os.environ.get('REDIS_PASSWORD'))
self.pubsub = self.redis_conn.pubsub()
self.pubsub.subscribe('XYZ_EVENTS')
for new_message in self.pubsub.listen():
    self._logger.info("received: " + str(new_message['data']))

had to set ssl=True and that did it.必须设置 ssl=True 就可以了。 the Elasticache instance has encryption enabled so this config had to be set to true. Elasticache 实例启用了加密,因此必须将此配置设置为 true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM