@@ -356,8 +356,6 @@ def on_connect(self):
356
356
)
357
357
auth_args = cred_provider .get_credentials ()
358
358
359
- auth_command_response = False
360
-
361
359
# try to send HELLO command (for Redis 6.0 and above)
362
360
try :
363
361
# if resp version is specified and we have auth args,
@@ -379,8 +377,6 @@ def on_connect(self):
379
377
except Exception as e :
380
378
if str (e ) == "Invalid RESP version" :
381
379
raise ConnectionError ("Invalid RESP version" )
382
- elif str (e ) == "Invalid Username or Password" :
383
- raise AuthenticationError ("Invalid Username or Password" )
384
380
# fall back to AUTH command (for Redis versions less than 6.0)
385
381
else :
386
382
self .send_command ('MULTI' )
@@ -391,6 +387,15 @@ def on_connect(self):
391
387
if auth_args :
392
388
self .send_command ("AUTH" , * auth_args , check_health = False )
393
389
auth_command_response = True
390
+ # avoid checking health here -- PING will fail if we try
391
+ # to check the health prior to the AUTH
392
+ if auth_args :
393
+ # check if only password is provided and RESP version < 6
394
+ if not self .username and self .password and self .protocol in [2 , "2" ]:
395
+ self .send_command ("AUTH" , self .password , check_health = False )
396
+ else :
397
+ self .send_command ("AUTH" , * auth_args , check_health = False )
398
+
394
399
395
400
# if a client_name is given, set it
396
401
if self .client_name :
0 commit comments