Feature Request: Add Automatic ForceReconnect Recovery for Persistent ConnectionMultiplexer Connection Failures

Offen
#3,309 9 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@meerasridharan-28 arbeitet bereits daran.

Seit 03.11.2026.

  • #3333 von @meerasridharan-28 — offen

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
38/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
csharp, redis
Bereich
backend, databases

Rechercherichtung

Start by reading ConfigurationOptions and the ConnectionMultiplexer reconnection and retry behavior, then review the six issue comments for implementation guidance or unresolved concerns. The issue proposes configurable automatic ForceReconnect recovery after persistent connection failures, with thresholds and limits; done means the recovery behavior and configuration are defined and work as described without forcing reconnects for transient errors.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Problem
StackExchange.Redis normally handles connection recovery automatically through ConnectionMultiplexer. However, there are scenarios where an application may continue experiencing connection failures after a connectivity disruption, and normal reconnection and recovery mechanisms may not restore healthy connectivity.

Microsoft documents the ForceReconnect pattern as an additional recovery mechanism for these scenarios.
https://learn.microsoft.com/en-us/azure/redis/best-practices-connection#using-forcereconnect-with-stackexchangeredis

Today application using Stackexchange.Redis directly must implement this additional ForceReconnect recovery logic themselves.

Proposal
Consider adding a guarded automatic recovery mechanism to StackExchange.Redis for persistent connection-level failures.

The intent is not to force reconnection for every RedisTimeoutException or transient connection error. The existing ConnectionMultiplexer reconnection and retry mechanisms should remain the first line of recovery.

Only when connection failures persist beyond a configurable threshold should the library consider triggering stronger ForceReconnect recovery.

Suggested API Changes

Consider extending ConfigurationOptions with the following properties to configure automatic recovery from persistent connection failures.

bool AutoForceReconnect // default True
public TimeSpan AutoForceReconnectErrorThreshold { get; set; } // default 30s
public TimeSpan AutoForceReconnectMinInterval //default 60s
public TimeSpan AutoForceReconnectMaxDuration //default 5 mins

example Usage

`var options = ConfigurationOptions.Parse(
    "localhost:6379");

options.AutoForceReconnect = true;
options.AutoForceReconnectErrorThreshold = TimeSpan.FromSeconds(30);
options.AutoForceReconnectMinInterval = TimeSpan.FromSeconds(60);
options.AutoForceReconnectMaxDuration = TimeSpan.FromMinutes(5);

var redis = await ConnectionMultiplexer.ConnectAsync(options);`

Configuration

AutoForceReconnect: Enables or disables automatic forced recovery. Defaults to true

AutoForceReconnectErrorThreshold: The duration of persistent connection-level failures required before forced recovery is considered.

AutoForceReconnectMinInterval: The minimum interval between forced recovery attempts to prevent excessive connection recycling.

AutoForceReconnectMaxDuration: The maximum duration for which automatic recovery attempts may continue during a persistent connectivity issue.

Vorherrschende Sprache
C#
Sterne
6.2k
Forks
1.6k
Ø Merge
9 Std. 42 Min.
Gemergte PRs (30 T.)
51

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus StackExchange/StackExchange.Redis

Alle Issues in StackExchange/StackExchange.Redis

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.