StackExchange.Redis
StackExchange.Redis copied to clipboard
Unable to debug azure redis cache locally from azure function app - Timeout performing SETEX
I have created an azure function app locally and created azure redis cache under premium plan in azure portal. I am trying to get/set cache by debugging the function app locally. I have used StackExchange.Redis 2.5.61 version. When I am trying to access the cache, its failing with below error -
{"Timeout performing SETEX (5000ms), inst: 0, qu: 1, qs: 0, aw: False, bw: SpinningDown, rs: NotStarted, ws: Idle, in: 0, serverEndpoint: test.cache.windows.net:6380, mc: 1/1/0, mgr: 10 of 10 available, clientName:, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=1,Free=32766,Min=8,Max=32767), POOL: (Threads=16,QueuedItems=0,CompletedItems=803), v: 2.5.61.22961 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)"}
The error message indicates the reader never started, meaning we didn't finish connecting to the endpoint. Is your connection string ignoring connection errors? e.g. abortConnect=false
? If so, remove that to get a better idea of what's erroring. Could be password, TLS protocols, or some other configuration mismatch in play as the most likely candidates.
If I remove that, I see the same error.. If I set that to true - I see "StackExchange.Redis.RedisConnectionException: 'It was not possible to connect to the redis server(s). Error connecting right now. To allow this multiplexer to continue retrying until it's able to connect, use abortConnect=false in your connection string or AbortOnConnectFail=false; in your code.'" I have tried increasing SyncTimeout, enforcing sslprotocols to Tls12. And, verified password from primary key/ primary connection string in azure redis cache. I am using premium redis cache in azure. what else could be causing this?
There are quite a few things that could be preventing the connection. I'd recommend trying the Azure troubleshooting guide, or opening an Azure support request if this doesn't solve it: https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-troubleshoot-connectivity#continuous-connectivity
I have tried everything, even deploying the app in same region as cache,, but still same error. I am using premium redis cache. Please let me know if you have any other idea -
"ExceptionMessage": "No connection is available to service this operation: SETEX key; UnableToConnect on cache.redis.cache.windows.net:6380/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.601.3402; IOCP: (Busy=0,Free=1000,Min=24,Max=1000), WORKER: (Busy=1,Free=32766,Min=24,Max=32767), Local-CPU: n/a",
"ExceptionType": "StackExchange.Redis.RedisConnectionException",
"StackTrace": " at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor1 processor, ServerEndPoint server) in C:\\projects\\stackexchange-redis\\src\\StackExchange.Redis\\ConnectionMultiplexer.cs:line 2232\r\n at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor
1 processor, ServerEndPoint server) in C:\projects\stackexchange-redis\src\StackExchange.Redis\RedisBase.cs:line 54\r\n at
"ExceptionMessage": "UnableToConnect on reporting-test-cache.redis.cache.windows.net:6380/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.601.3402",
"ExceptionType": "StackExchange.Redis.RedisConnectionException",
"StackTrace": " at StackExchange.Redis.TaskExtensions.TimeoutAfter(Task task, Int32 timeoutMs) in C:\\projects\\stackexchange-redis\\src\\StackExchange.Redis\\TaskExtensions.cs:line 49\r\n at StackExchange.Redis.ConnectionMultiplexer.WaitAllIgnoreErrorsAsync(Task[] tasks, Int32 timeoutMilliseconds, LogProxy log, String caller, Int32 callerLineNumber) in C:\\projects\\stackexchange-redis\\src\\StackExchange.Redis\\ConnectionMultiplexer.cs:line 672"
}
That error message indicates that you're using a fairly old v2.0.601.3402 of the library - I'd highly recommend upgrading to 2.6.45+.
Are you including ssl=true
your connection string, and connecting from a client that supports TLS 1.2? See:
https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-remove-tls-10-11
https://techcommunity.microsoft.com/t5/azure-paas-blog/azure-cache-for-redis-tls-versions/ba-p/1549630
I started with the latest version and tried almost all versions.. I read downgrading from some other link so tried that.. With the latest version, I see just timeout.. like I said in my first comment.. And,I did include ssl = true and sslprotocols = tls12, increased timeouts.. And, verified that function app is using tls 1.2. Nothing helped to fix that.. my function app and redis cache both are in same region. And I am using .net core 3.1
It looks like public network access is disabled on your cache. You'll need to enable it with these instructions: https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-private-link#how-can-i-change-my-private-endpoint-to-be-disabled-or-enabled-from-public-network-access
I did enable it here - it just gives message for a second - the update is in progress.. doesnt say if its actually enabled..
I don't see the request to enable Public Network Access coming through for this cache, so you may be encountering a bug. I'll investigate more from the Azure side. Meanwhile, you have a couple options for getting unblocked:
- Create a new cache with Public Network Access enabled from the start. You can always switch later to disable public access and connect via a Private Link instead.
- Add a Private Link and connect through that
I tried creating cache with public endpoint enabled from start or using the private link - I still get same error...
Timeout performing SETEX (5000ms), inst: 0, qu: 1, qs: 0, aw: False, bw: SpinningDown, rs: NotStarted, ws: Initializing, in: 0, serverEndpoint: .redis.cache.windows.net:6380, mc: 1/1/0, mgr: 10 of 10 available, clientName: (SE.Redis-v2.6.45.45955), IOCP: (Busy=0,Free=1000,Min=24,Max=1000), WORKER: (Busy=1,Free=32766,Min=24,Max=32767), POOL: (Threads=13,QueuedItems=0,CompletedItems=477), v: 2.6.45.45955 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)",
"ExceptionType": "StackExchange.Redis.RedisTimeoutException",
There are a few more initial connection speed optimizations release in latest (2.6.70) but my read above is you can't connect at all which still appears to be a network or configuration issue. Still, I wanted to pass along the library update piece because once your other blocker is resolved, this will connect much faster.
We've added more info to the exception here for relevant cases like this, but inability to connect in this one is a config issue, hope you were able to figure out network/hosting config here!