Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RedisConnectionException: No connection is available to service this operation: EVAL

I'm trying to implement Redis in an ASP.NET WebForms application (4.7.2). I downloaded the SessionProvider source code from https://github.com/Azure/aspnet-redis-providers. I'm using StackExchange.Redis 2.0+ .

After the login has been executed, this error is thrown:

enter image description here

Apparently, an attempt to eval some Lua script was made, and it failed (that was the conclusion for the closure of the StackExchange.Redis related issue).

So, assuming that assumption is correct, I extracted the offending script, and ran it with redis-cli --eval along with the keys and arguments.

local retArray = {} 
local lockValue = ARGV[1] 
local locked = redis.call('SETNX',KEYS[1],ARGV[1])        
local IsLocked = true

if locked == 0 then
    lockValue = redis.call('GET',KEYS[1])
else
    redis.call('EXPIRE',KEYS[1],ARGV[2])
    IsLocked = false
end

retArray[1] = lockValue
if lockValue == ARGV[1] then retArray[2] = redis.call('HGETALL',KEYS[2]) else retArray[2] = '' end

local SessionTimeout = redis.call('HGET', KEYS[3], 'SessionTimeout')
if SessionTimeout ~= false then 
    retArray[3] = SessionTimeout 
    redis.call('EXPIRE',KEYS[2], SessionTimeout) 
    redis.call('EXPIRE',KEYS[3], SessionTimeout) 
else 
    retArray[3] = '-1' 
end

retArray[4] = IsLocked
return retArray

It was successful.

enter image description here

Are there other issues that might throw this exception?

EDIT: Upgraded to 2.0. Still suffering from the same issues.

like image 693
Eric Wu Avatar asked Nov 06 '22 11:11

Eric Wu


1 Answers

I tried to research for your issue, and then I found there is an issue No connection is available to service this operation using v.1.2.6 #762 of GitHub StackExchange/StackExchange.Redis repo which seems to be same with yours.

According to the note of a comment at the bottom of the GitHub issue, the other issue The "network stability" / 2.0 / "pipelines" rollup issue #871, there are some bugs need to be fixed for the version under 2.0, which likes network connection stability issue.

So I suggested that you can upgrade your current StackExchange.Redis (V1.2.6) to a latest stable 2.x version and try your code again. Meanwhile, please notice the Release Notes of Azure/aspnet-redis-providers to make the right and compatible versions to support your current code.

like image 177
Peter Pan Avatar answered Nov 27 '22 22:11

Peter Pan