Managed Redis fails with StackExchange.Redis.RedisConnectionException after a few days of usage and does not return to e healthy state

Sven Carstensen 5 Reputation points
2025-06-10T06:46:26.74+00:00

We are using Azure Managed Redis, running in Balanced B0, size 0.5GB, location West Europe.

After a few days our Container Apps (.NET 9) cannot connect anymore and get the following two exceptions:

The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: UnableToConnect (0-sent) on XYZ.westeurope.redis.azure.net:10000/Interactive, Flushed/ReadAsync, last: ECHO, origin: ResetNonConnected, outstanding: 13, last-read: 5s ago, last-write: 4s ago, unanswered-write: 4s ago, keep-alive: 60s, state: ConnectedEstablishing, mgr: 10 of 10 available, last-heartbeat: never, global: 5s ago, v: 2.8.24.3255, command=HGET, timeout: 5000, inst: 0, qu: 2, qs: 0, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 0, async-ops: 9, serverEndpoint: XYZ.westeurope.redis.azure.net:10000, conn-sec: 22.99, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: abc (SE.Redis-v2.8.24.3255), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=0,Free=32767,Min=1,Max=32767), POOL: (Threads=7,QueuedItems=0,CompletedItems=441,Timers=19), v: 2.8.24.3255

The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: It was not possible to connect to the redis server(s). There was an authentication failure; check that passwords (or client certificates) are configured correctly: (RedisServerException) Error: WRONGPASS invalid username-password pair ConnectTimeout, command=HMSET, timeout: 5000, inst: 0, qu: 1, qs: 0, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 9, async-ops: 568, serverEndpoint: XYZ.westeurope.redis.azure.net:10000, conn-sec: 16.79, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: ABC (SE.Redis-v2.8.24.3255), PerfCounterHelperkeyHashSlot: 10240, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=77,Free=32690,Min=1,Max=32767), POOL: (Threads=106,QueuedItems=1,CompletedItems=2321851,Timers=27), v: 2.8.24.3255

We use a user managed identity to connect. That identity can connect to other services like Azure table. So, the identity is existing and valid.

The only way we could get Redis working again was by deleting and recreating the Redis resource.

Monitoring is not showing any problems: 2MB used. Server load 30 to 60% - which is interesting because our apps can't connect. Connected Clients and Total Operations show both 10 with Count aggregation.

Any idea what could cause this?

Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
{count} votes

3 answers

Sort by: Most helpful
  1. PratikLad 1,905 Reputation points Microsoft External Staff Moderator
    2025-06-19T16:49:16.7933333+00:00

    Hi Sven Carstensen,

    You can refer to the official Document on Cache management FAQs - Azure Cache for Redis | Microsoft Learn for detailed information.

    The timeout exception and the following connection error from StackExchange.Redis indicate potential client-side performance bottlenecks, particularly related to .NET ThreadPool usage:

    
    RedisServerException) Error: WRONGPASS invalid username-password pair ConnectTimeout, command=HMSET, timeout: 5000, inst: 0, qu: 1, qs: 0, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 9, async-ops: 568, serverEndpoint: XYZ.westeurope.redis.azure.net:10000, conn-sec: 16.79, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: ABC (SE.Redis-v2.8.24.3255), PerfCounterHelperkeyHashSlot: 10240, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (**Busy=77**,Free=32690,Min=1,Max=32767), POOL: (Threads=106,QueuedItems=1,CompletedItems=2321851,Timers=27), v: 2.8.24.3255
    
    

    This log shows that 77 worker threads were busy at the time of the failure, while the ThreadPool’s minimum thread count was just 1.

    When the number of busy threads exceeds the minimum, the .NET ThreadPool throttles thread creation, which can delay Redis operations and lead to TimeoutException errors. You can read more about this behavior in:

    Increase the minimum thread count early in your app's lifecycle. Add this line of code as early as possible (e.g., in Program.cs, Application_Start(), or the main method):

    
    System.Threading.ThreadPool.SetMinThreads(200, 200);
    
    
    • This is not per-core: the values apply globally.
    • Start with 200 and monitor; if the busy thread count still exceeds that, increase accordingly.

    Monitor CPU and memory usage of the container or VM. If your Redis client is under heavy CPU/memory load, this can exacerbate timeouts.

    Scale your application appropriately:

    While these client-side performance improvements are crucial, please note that the "WRONGPASS" error also indicates a possible authentication issue (e.g., with Managed Identity or token expiration). If you're using Azure Managed Identity, ensure token handling and Redis connection setup are configured correctly.


  2. Wilson Wang 0 Reputation points Microsoft Employee
    2025-07-08T08:40:48.9033333+00:00

    Hi, I am facing similar issue in my client application calling Azure Managed Redis.

    I am configuring the connection property and run my client application as below ( I have already granted my personal azure account access to the Azure Managed Redis instance):
    var credential = new InteractiveBrowserCredential();

    configOptions.ConfigureForAzureWithTokenCredentialAsync(credential).GetAwaiter();

    configOptions.Ssl = true;

    configOptions.AbortOnConnectFail = false;

    configOptions.ConnectTimeout = 10000;

    configOptions.SyncTimeout = 10000;

    configOptions.AllowAdmin = true;

    var muxer = await ConnectionMultiplexer.ConnectAsync(configOptions);

    var db = muxer.GetDatabase(redisDatabaseId);

    it always gives me error if I send more than 1 requests sequentially:
    Error: The message timed out in the backlog attempting to send because no connection became available, command=SETEX, timeout: 10000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 6, async-ops: 13, serverEndpoint: 52.250.47.169:8502, conn-sec: 11.71, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: CPC-shisw-I7HZC(SE.Redis-v2.8.24.3255), PerfCounterHelperkeyHashSlot: 8210, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=0,Free=32767,Min=16,Max=32767), POOL: (Threads=11,QueuedItems=0,CompletedItems=1760,Timers=3), v: 2.8.24.3255 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)

    However, if I use access key to authenticate to the Redis:
    var configOptions = ConfigurationOptions.Parse($"{redisHostname}:{redisPort}");

    configOptions.Ssl = true;

    configOptions.AbortOnConnectFail = false;

    configOptions.ConnectTimeout = 10000;

    configOptions.SyncTimeout = 10000;

    configOptions.AllowAdmin = true;

    configOptions.Password = "{my access key}"

    var muxer = await ConnectionMultiplexer.ConnectAsync(configOptions);

    It can always succeed, no matter how many requests were sent to Redis.

    My redis capacity is very sufficient, see below, I only send hundreds of requests from local machine, there is no server load issue to worry about.
    User's image

    Can you help on this issue ?

    0 comments No comments

  3. Sven Carstensen 5 Reputation points
    2025-08-15T06:52:58.8433333+00:00

    We opened a support case and finally the problem was solved by the product group of Redis. Since 13th of August we can connect again with managed identities.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.