Skip to content

DistributedCache : ForceReconnect does not work correctly with ConnectionMultiplexerFactory #55898

Open
@FPierrel

Description

@FPierrel

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Our application runs on Azure App Service (Linux) in a docker container.

Following numerous lost connections to the Redis cache, we activated ForceReconnect with the switch “Microsoft.AspNetCore.Caching.StackExchangeRedis.UseForceReconnect”.

This worked fine until we used ConnectionMultiplexerFactory in the StackExchangeRedisCache configuration: the factory connection was released but never reconnected :

IConnectionMultiplexer connection;
if (_options.ConnectionMultiplexerFactory is null)
{
connection = ConnectionMultiplexer.Connect(_options.GetConfiguredOptions());
}
else
{
connection = _options.ConnectionMultiplexerFactory().GetAwaiter().GetResult();
}
On subsequent requests, ObjectDisposedExceptions are thrown.

Is this the expected behavior? Is it better to modify the Factory to take account of this case (taking into account other services using it) or to disable the ForceReconnect pattern, which is probably useless since StackExchange/StackExchange.Redis#2610 ?

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0

Anything else?

Microsft.Extensions.Caching.StackExchangeRedis : 8.0.3
StackExchange.Redis : 2.7.33

Metadata

Metadata

Assignees

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-cachingIncludes: StackExchangeRedis and SqlServer distributed caches

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions