Search code examples
azureazure-functionsazure-redis-cache

Not able to connect with Azure Redis cache


I completely fed up with Azure Redis cache with function.

Below line of "Test Code" working in console application but not working with Azure Function.

IConnectionMultiplexer connection = ConnectionMultiplexer.Connect("**********rediscache.redis.cache.windows.net:6380,password=nFpm1oIiyP8ZiCxC/WMcxaFRzGo4yMgWDYZksQgqO4U=,ssl=True,abortConnect=False");
        IDatabase database = connection.GetDatabase();
        bool isConnected = connection.IsConnected;
        var test = database.HashExists("key", "fieldKey");
        database.HashSet("key", "fieldKey", "test");

        database.StringSet("Key", "Value");
        var result = database.StringGet("Key");
        connection.Close();

Using Azure function from Visual Studio

Nuget - StackExchange.Redis 2.0.505 & Microsoft.NET.Sdk.Functions 1.0.22

 Exception while executing function: Function1. StackExchange.Redis: 
No connection is available to service this operation: HEXISTS key; 
UnableToConnect on 
catamsrediscache.redis.cache.windows.net:6380/Interactive, 
Flushed, last: ECHO, origin: ResetNonConnected, outstanding: 9, last-read: 
5s ago, last-write: 0s ago, unanswered-write: 0s ago, keep-alive: 60s, 
state: ConnectedEstablishing, mgr: 10 of 10 available, last-heartbeat: 
never, global: 
0s ago, v: 2.0.505.18761; IOCP: (Busy=0,Free=1000,Min=4,Max=1000), WORKER: 
(Busy=2,Free=1021,Min=4,Max=1023), Local-CPU: n/a. UnableToConnect on     
catamsrediscache.redis.cache.windows.net:6380/Interactive, Flushed, last: 
ECHO,     origin: ResetNonConnected, outstanding: 9, last-read: 5s ago, 
last-write: 0s ago, unanswered-write: 0s ago, keep-alive: 60s, state: 
ConnectedEstablishing, mgr: 10 of 10 available, last-heartbeat: never, 
global: 0s ago, v: 2.0.505.18761.

Anyone know why this error coming in function only?


Solution

  • I had the same error and have to update StackExchange.Redis Nuget package to 1.2.6.

    Now issue resolved with StackExchange.Redis 2.0.519