As per title,
I am struggling to make a connection with a Redis cluster using the redis.asyncio library (it works perfectly fine with master/slave configuration). I created a simple test to check the connection and it timeouts. Surely I got something wrong here:
import asyncio
from redis.asyncio.cluster import RedisCluster
async def test_redis_connection():
try:
# Connect to the Redis cluster
redis = RedisCluster.from_url(‘redis://localhost:6379′, encoding=’utf-8’, decode_responses=True)
# Test the connection by setting and getting a value
await redis.set('key1', 'bar')
value = await redis.get('key1')
# Print the result
print(f"Connection successful, value: {value}")
# Close the connection
await redis.close()
except Exception as e:
print(f"Connection failed: {e}")
For completeness, the redis cluster lives in my k8s cluster, the cluster is deployed using the bitnami redis-cluster chart, and I am port-forwarding the created service.