As the Sample shows, we add some event loggings in our app based on IAzureCacheTokenEvents and ConnectionMultiplexer just like:
if (configurationOptions.Defaults is IAzureCacheTokenEvents tokenEvents)
{
tokenEvents.TokenRefreshed += (sender, tokenResult) => logger.Info($"Redis Cache token refreshed. New token will expire at {tokenResult.ExpiresOn}");
tokenEvents.TokenRefreshFailed += (sender, args) => logger.Error($"Redis Cache token refresh failed for token expiring at {args.Expiry}: {args.Exception}");
tokenEvents.ConnectionReauthenticated += (sender, endpoint) => logger.Info($"Redis Cache re-authenticated connection to '{endpoint}'");
tokenEvents.ConnectionReauthenticationFailed += (sender, args) => logger.Error($"Redis Cache re-authentication of connection to '{args.Endpoint}' failed: {args.Exception}");
}
connectionMultiplexer.ConfigurationChanged += (sender, args) =>
{
logger.Info($"Redis connecntion configuration is changed at {args.EndPoint}");
};
connectionMultiplexer.ConnectionFailed += (sender, args) =>
{
logger.Error($"Redis connecntion is failed at {args.EndPoint}, FailureType: {args.FailureType}, Exception Message: {args.Exception?.Message}.");
};
connectionMultiplexer.ConnectionRestored += (sender, args) =>
{
logger.Info($"Redis connecntion is restored at {args.EndPoint}, FailureType: {args.FailureType}, Exception Message: {args.Exception?.Message}.");
};
connectionMultiplexer.ErrorMessage += (sender, args) =>
{
logger.Warn($"Redis connecntion is responding with error message at {args.EndPoint}, Message: {args.Message}.");
};
But we got a strange error loggings that, the ConnectionFailed event will always occur when the token is going to be expired even if there is already a newer token has been generated.
Here is some loggings. I highlight the relevant logging with same color.
As you can see, the yellow-highlight token(which not trigger re-authenticated) should be an older token than green-highlight token(which also triggered re-authenticated). But at about 2024-11-20 02:46:02.2908495, the connection was failed and it looked like it was due to the expiration of yellow token. Since the green token was generated, I supposed it should not happen.
Similar issue happend in blue token and purple token.
It is also strange that the yellow token didn't trigger "re-authenticated" event. Was is just due to the expired time of yellow token was not greater than the existing one? (I see there could be some relevant if-else checking for that in AzureCacheOptionsProviderWithToken.cs)
The version we are using is 2.0.0. I saw some other "SocketClosed" issues before and someone suggested upgrading to version 3.1.0
However, I can't see any related code change or released note for my issue.

As the Sample shows, we add some event loggings in our app based on IAzureCacheTokenEvents and ConnectionMultiplexer just like:
But we got a strange error loggings that, the ConnectionFailed event will always occur when the token is going to be expired even if there is already a newer token has been generated.
Here is some loggings. I highlight the relevant logging with same color.
As you can see, the yellow-highlight token(which not trigger re-authenticated) should be an older token than green-highlight token(which also triggered re-authenticated). But at about 2024-11-20 02:46:02.2908495, the connection was failed and it looked like it was due to the expiration of yellow token. Since the green token was generated, I supposed it should not happen.
Similar issue happend in blue token and purple token.
It is also strange that the yellow token didn't trigger "re-authenticated" event. Was is just due to the expired time of yellow token was not greater than the existing one? (I see there could be some relevant if-else checking for that in AzureCacheOptionsProviderWithToken.cs)
The version we are using is 2.0.0. I saw some other "SocketClosed" issues before and someone suggested upgrading to version 3.1.0
However, I can't see any related code change or released note for my issue.