Azure / Microsoft.Azure.StackExchangeRedis

Azure-specific wrapper for the StackExchange.Redis client library
MIT License
17 stars 14 forks source link

Connection Reauthentication always fails #51

Closed a99cl208 closed 5 months ago

a99cl208 commented 5 months ago

Hello,

Package v3.0.0 introducted the GetUserName function here: https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/blob/main/src/AzureCacheOptions.cs#L81 Which is used to assign the User property on the ConfigurationOptions here: https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/blob/main/src/AzureCacheForRedis.cs#L116

However, the function is not used to override the User property of the AzureOptionsProvider base class of AzureCacheOptionsProviderWithToken which is assigned to ConfigurationOptions.Default here: https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/blob/main/src/AzureCacheForRedis.cs#L115

As a consequence, when the reauthentication is done here: https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/blob/main/src/AzureCacheOptionsProviderWithToken.cs#L241 The User property passed is null because not overridden (as it was in v2.0.0 of the package).

This makes the execution failed systematically, with error "ERR protocol error: invalid bulk length".

To solve this bug, you have to override the User property inside the AzureCacheOptionsProviderWithToken class, and assign its value from the GetUserName function of the AzureCacheOptions

philon-msft commented 5 months ago

Hi @a99cl208 thanks for the detailed bug report. Please take a look at PR #52

a99cl208 commented 5 months ago

Looks good to me!

philon-msft commented 5 months ago

Fixed in PR #52. Version 3.1.0 including this fix will be released shortly. Thanks for your feedback!