Skip to content

RESP3 default in 8.0 breaks connections to servers/proxies that don't support HELLO (no fallback) #4089

Description

@yangbodong22011

Problem

redis-py 8.0 changed DEFAULT_RESP_VERSION from 2 to 3 (PR #4031). When connecting to a Redis server < 6.0 or a proxy that doesn't support the HELLO command, the connection fails immediately with ResponseError: unknown command — there is no automatic fallback to RESP2.

Root Cause

on_connect_check_health() in connection.py:1111-1114:

self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False)
self.handshake_metadata = self.read_response()  # no try-except, raises directly

Unlike Lettuce, Jedis, and go-redis which catch HELLO failures and fall back to legacy AUTH, redis-py raises the error and the connection is never established.

Impact

Users upgrading from 7.x to 8.0 with zero code changes will experience immediate connection failures if their server/proxy doesn't support HELLO. This includes:

  • Redis < 6.0
  • Certain managed Redis proxies
  • Third-party Redis-compatible services that haven't implemented HELLO

Suggested Fix

Catch ResponseError from the HELLO command and fall back to RESP2 + standalone AUTH, similar to what other clients do:

try:
    self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False)
    self.handshake_metadata = self.read_response()
except ResponseError:
    # Server doesn't support HELLO, fall back to RESP2 AUTH
    if isinstance(self._parser, _RESP3Parser):
        self.set_parser(_RESP2Parser)
        self._parser.on_connect(self)
    self.protocol = 2
    self.send_command("AUTH", *auth_args, check_health=False)
    auth_response = self.read_response()
    if str_if_bytes(auth_response) != "OK":
        raise AuthenticationError("Invalid Username or Password")

Workaround

redis.Redis(host=host, port=port, password=password, protocol=2)

Explicitly setting protocol=2 avoids the HELLO path entirely.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions