dotnet / dotnet/aspnetcore

Redis reconnect problem

Open
#5,393 2 comments 0 reactions 0 assignees View on GitHub
affected-few area-signalr enhancement severity-major
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

In our web application,when there is a problem with the redis cluster.The configcenter will automatically issue new cluster connections,and old connections will be cleared.In this case, redis needs to reconnect.But there is no way to do this now, I have to restart the application.

Therefore, I modified the following code to solve this problem
```
_redisServerConnection.ConnectionFailed += (_, e) =>
{
// We use the subscription connection type
// Ignore messages from the interactive connection (avoids duplicates)
if (e.ConnectionType == ConnectionType.Interactive)
{
return;
}
RedisLog.ConnectionFailed(_logger, e.Exception);
// When ConnectionFailed ,try reconnect
_redisServerConnection = await _options.ConnectAsync(writer);
_bus = _redisServerConnection.GetSubscriber();
};
```
Any Suggestions for this situation?

Contributor guide

Open the contributing guide

Research direction

The issue does not name a repository file or test; start by locating the code that owns _redisServerConnection.ConnectionFailed, _options.ConnectAsync(writer), and the subscriber assigned to _bus. Trace how cluster connection replacement is handled and verify the application reconnects and resumes Redis use without a restart.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.