From 9559454a94a95e0914a49fb03e80c4eb162694f7 Mon Sep 17 00:00:00 2001 From: Antoni Baum Date: Thu, 9 Jan 2025 16:55:19 -0800 Subject: [PATCH 1/4] Update connection.py --- redis/asyncio/connection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 8c3123ac04..8a88325ee8 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -350,7 +350,9 @@ async def on_connect(self) -> None: self._parser.on_connect(self) if len(auth_args) == 1: auth_args = ["default", auth_args[0]] - await self.send_command("HELLO", self.protocol, "AUTH", *auth_args) + # avoid checking health here -- PING will fail if we try + # to check the health prior to the AUTH + await self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False) response = await self.read_response() if response.get(b"proto") != int(self.protocol) and response.get( "proto" From 375887a809f99d89218ce3e666e7498758bf1f2b Mon Sep 17 00:00:00 2001 From: Petya Slavova Date: Tue, 4 Mar 2025 17:43:15 +0200 Subject: [PATCH 2/4] Adding check_health=False for RESP3 on_connect when auth creds are provided. --- redis/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/connection.py b/redis/connection.py index ece17d752b..19f9f771a6 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -440,7 +440,7 @@ def on_connect(self): self._parser.on_connect(self) if len(auth_args) == 1: auth_args = ["default", auth_args[0]] - self.send_command("HELLO", self.protocol, "AUTH", *auth_args) + self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False) self.handshake_metadata = self.read_response() # if response.get(b"proto") != self.protocol and response.get( # "proto" From 16f50161b7d5ff71e451a55b9a32e03aa69deb9e Mon Sep 17 00:00:00 2001 From: Petya Slavova Date: Tue, 4 Mar 2025 17:50:15 +0200 Subject: [PATCH 3/4] Fix linter errors. --- redis/asyncio/connection.py | 4 +++- redis/connection.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index a67cbf799c..2e2a2502c3 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -365,7 +365,9 @@ async def on_connect(self) -> None: auth_args = ["default", auth_args[0]] # avoid checking health here -- PING will fail if we try # to check the health prior to the AUTH - await self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False) + await self.send_command( + "HELLO", self.protocol, "AUTH", *auth_args, check_health=False + ) response = await self.read_response() if response.get(b"proto") != int(self.protocol) and response.get( "proto" diff --git a/redis/connection.py b/redis/connection.py index 19f9f771a6..46951facd1 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -440,7 +440,9 @@ def on_connect(self): self._parser.on_connect(self) if len(auth_args) == 1: auth_args = ["default", auth_args[0]] - self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False) + self.send_command( + "HELLO", self.protocol, "AUTH", *auth_args, check_health=False + ) self.handshake_metadata = self.read_response() # if response.get(b"proto") != self.protocol and response.get( # "proto" From d709973408c0e8c2877f517f444d7a21caec06be Mon Sep 17 00:00:00 2001 From: Petya Slavova Date: Tue, 4 Mar 2025 19:07:25 +0200 Subject: [PATCH 4/4] Adding comment why we are skipping the health check for resp3 on HELLO command - for sync connection --- redis/connection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/redis/connection.py b/redis/connection.py index 46951facd1..2391e74d2c 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -440,6 +440,8 @@ def on_connect(self): self._parser.on_connect(self) if len(auth_args) == 1: auth_args = ["default", auth_args[0]] + # avoid checking health here -- PING will fail if we try + # to check the health prior to the AUTH self.send_command( "HELLO", self.protocol, "AUTH", *auth_args, check_health=False )