【问题标题】:Azure Redis Cache StackExchange.Redis.RedisConnectionException: No connection is available to service this operation: EVALAzure Redis 缓存 StackExchange.Redis.RedisConnectionException:没有可用于服务此操作的连接:EVAL
【发布时间】:2016-03-14 18:40:12
【问题描述】:

Asp.net mvc 5 应用程序 web 配置文件是

   sessionState mode="Custom" customProvider="RedisSessionProvider">
      providers>
add name="RedisSessionProvider" type="Microsoft.Web.Redis.RedisSessionStateProvider" port="6380" host="XXX.redis.cache.windows.net" accessKey="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" ssl="true" />
 providers>
    sessionState>

当我运行应用程序时出现错误

Server Error in '/' Application.
No connection is available to service this operation: EVAL
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: StackExchange.Redis.RedisConnectionException: No connection is available to service this operation: EVAL
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[RedisConnectionException: No connection is available to service this operation: EVAL]
   StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl(Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:1922
   StackExchange.Redis.RedisBase.ExecuteSync(Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:80
   StackExchange.Redis.RedisDatabase.ScriptEvaluate(String script, RedisKey[] keys, RedisValue[] values, CommandFlags flags) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisDatabase.cs:866
   Microsoft.Web.Redis.<>c__DisplayClass4.<Eval>b__3() in c:\TeamCity\buildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:113
   Microsoft.Web.Redis.StackExchangeClientConnection.RetryForScriptNotFound(Func`1 redisOperation) in c:\TeamCity\buildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:129
   Microsoft.Web.Redis.StackExchangeClientConnection.RetryLogic(Func`1 redisOperation) in c:\TeamCity\buildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:155
   Microsoft.Web.Redis.StackExchangeClientConnection.Eval(String script, String[] keyArgs, Object[] valueArgs) in c:\TeamCity\buildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:113
   Microsoft.Web.Redis.RedisConnectionWrapper.Set(ISessionStateItemCollection data, Int32 sessionTimeout) in c:\TeamCity\buildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisConnectionWrapper.cs:135
   Microsoft.Web.Redis.RedisSessionStateProvider.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) in c:\TeamCity\buildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisSessionStateProvider.cs:408
   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +906
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +142
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +92
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0

【问题讨论】:

    标签: azure caching redis azure-caching azure-redis-cache


    【解决方案1】:

    我也有同样的问题,最终通过将sslprotocols=tls12 添加到连接字符串来修复它。它不应该是必要的,但显然它是在 Azure 上使用最近创建的 Redis 缓存。可能是由于 TLS 1.0 和 1.2 的弃用

    【讨论】:

      【解决方案2】:

      可能有 3 个原因:

      1. 您的连接字符串错误(无论如何都可以)
      2. 尚未创建实例(在 azure 中创建通常需要很多时间)
      3. 您面临防火墙(包括 Windows 防火墙)问题

      您是否能够使用命令提示符连接到 redis 缓存实例?

      下载redis for windows Here

      然后运行

      redis-cli -h XXX.redis.cache.windows.net -a XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 
      

      您可以在此处找到详细的演示(西班牙语版本,但控制台演示仍然可用。)

      NinjaTip #18 - Introducción a Redis

      出于测试目的,请确保 Redis 服务已打开端口 6379(这是您需要在 azure 上启用的非 SSl 端口选项)

      如果您无法连接到您的实例是因为上面列出的一些原因。

      【讨论】:

      • 我检查连接字符串和它的确定,检查实例 wzs 创建。你能帮我如何更改 azure 服务器上的防火墙吗?
      • 不是天蓝色防火墙。查看本地防火墙或 Windows 防火墙
      • 防火墙被禁用。
      • 你可以使用命令提示符连接到redis缓存实例吗?
      • 不,我从 azure 门户添加了 redis 缓存。
      【解决方案3】:

      我之前遇到过同样的问题,但我找到了使用另一个解决方案的解决方案: https://github.com/alex-simonov/RedisAspNetProviders

      这个适合我

      【讨论】:

        【解决方案4】:

        我发现只有 web config 中的以下配置对我有用:

        <sessionState mode="Custom" customProvider="MySessionStateStore">
          <providers>
            <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="PUTCORRECTNAMEHERE.edis.cache.windows.net:6380,password=YOURPRIMARYKEYPUTHERE,ssl=True,abortConnect=False" />
          </providers>
        </sessionState>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-04-01
          • 2018-05-06
          • 2019-11-25
          • 1970-01-01
          • 2014-05-20
          • 1970-01-01
          • 1970-01-01
          • 2014-07-09
          相关资源
          最近更新 更多