Skip to content

AsyncRedisManager breaks in loop: "Cannot receive from redis..." with redis-py 8.0.0 (RESP3) #1585

@Fahad-Rashid-TecnoFuzion

Description

Describe the bug
When using socketio.AsyncRedisManager (or RedisManager) with the newly released redis==8.0.0 package, the application gets stuck in an infinite loop printing:

Cannot receive from redis... retrying in 1 secs

This only happens with redis==8.0.0 and appears to be caused by the change in default protocol from RESP2 to RESP3.

To Reproduce

  1. Install:
    • python-socketio (version: 5.16.3)
    • redis==8.0.0
  2. Configure AsyncRedisManager (or RedisManager) using redis.from_url(...) with default settings (no explicit protocol argument).
  3. Start the Socket.IO server and any worker processes that use the same Redis manager.
  4. Trigger events that cause inter-process messages (so that Redis pub/sub is used).

Observed behavior
The process handling the Redis pub/sub channel gets stuck in an infinite loop, logging repeatedly:

Cannot receive from redis... retrying in 1 secs

Inter-process messaging via Redis does not work.

Expected behavior
The Redis pub/sub consumer should correctly receive and parse messages so that inter-process communication works normally, without entering a retry loop.

Root cause (analysis)
In redis-py 8.0.0, the default protocol was changed to RESP3 (protocol=3). The _redis_listen_with_retries / pub-sub consumer used by python-socketio assumes RESP2-style message structures, and fails to parse the incoming pub/sub messages when Redis is speaking RESP3. This causes the consumer to fail and re-enter the retry path continuously.

Temporary workaround
Downgrading to redis<8.0.0 restores RESP2 as the default and resolves the issue immediately.

Alternatively, forcing RESP2 when constructing the Redis client (e.g. redis.from_url(..., protocol=2)) also avoids the problem. (not tested but it should work)

Proposed fix
Until python-socketio natively supports RESP3 pub/sub message structures, the Redis-based managers should either:

  • Explicitly pass protocol=2 when instantiating the Redis client connection via redis.from_url(...), or
  • Document that redis>=8.0.0 (RESP3 default) is currently unsupported and that users must either:
    • pin redis<8.0.0, or
    • explicitly pass protocol=2 in their own Redis client configuration.

Environment

  • python-socketio version: 5.16.3
  • redis-py version: 8.0.0
  • Python version: 3.12.13
  • OS: macOS Tahoe 26.5.1

Logs
Representative log output:

Cannot receive from redis... retrying in 1 secs

Additional context
The same pattern occurs in my own project when using AsyncRedisManager against Redis with RESP3 enabled. Downgrading redis-py or forcing RESP2 removes the issue immediately.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions