Skip to content
Advertisement

Unable to connect to AWS ElastiCache form python client

I have an AWS ElastiCache instance of 2 replicated nodes (cluster-mode disabled). I am able to connect through my java client using redisson (a service running in the same cluster). However, when I’m using the python redis client, it does not seem to connect. 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. Not sure what I’m doing wrong. Also it works if I’m connecting to a local redis instance. 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']))

Advertisement

Answer

had to set ssl=True and that did it. the Elasticache instance has encryption enabled so this config had to be set to true.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement