#Channels Plugin bug when using RedisPubSub
1 messages · Page 1 of 1 (latest)
It doesn't work with decode_responses=True because it operates on a bytes level. If it would allow arbitrary objects, that would make things much more complicated, since you'd then need to pass information along about how to serialise these objects before sending them over the socket
You should really give it its own redis client
It should work with a connection pool though. Can you share what you've got right now that's not working?
This is how I create my connection pool.
# In some function
import redis.asyncio as redis_async
if not cls._pool:
cls._pool = redis_async.ConnectionPool.from_url(
f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}",
decode_responses=True, # also tried removing this and it doesn't work.
)
return redis_async.Redis(connection_pool=cls._pool)
But when I tried it with separate connection directly from Redis instance, it works but without decode_responses=True (||I didn't tried to add it again after so many workarounds since I can't really make it work||)
# this works
def get_pubsub_client(cls) -> redis_async.Redis:
if cls._pool is None:
cls._pubsub_client = redis_async.from_url(
f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}",
)
_logger.info(f"Redis pubsub client started successfully")
return cls._pubsub_client
Can you share the context? With just this bit it's hard to tell what the issue is
it's probably helpful to know what version is your redis client as well. It's possible something they've done in recent releases could be at play. (or if this is valkey, redis enterprise, etc.)