-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
Hi,
I have a redis server hosted by aws using aws ElastiCache. When I try to connect to it using a lambda and on my local machine, it gives 'timeout connecting to server' error. However, my colleague could connect to this redis using another client in PHP.
I wonder what I did wrong.
try:
redisClient = redis.Redis(host='***.use1.cache.amazonaws.com', port=6379, db=0, socket_timeout=10)
print(redisClient)
try:
print(redisClient.ping())
print(redisClient.set('foo','bar'))
# r.get('foo')
except Exception as e:
print('get set error: ', e)
except Exception as e:
print('redis err: ', e)
// redisClient Redis<ConnectionPool<Connection<host=***.use1.cache.amazonaws.com,port=6379,db=0>>>
// get set error: Timeout connecting to server for ping or set
Without setting the socket_timeout parameter, it will time out based on redis-py operation timeout:
Error 60 connecting to ***.use1.cache.amazonaws.com:6379. Operation timed out.