5

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
4

4 に答える 4

3

次の 3 つの理由が考えられます。

  1. 接続文字列が間違っています (どう見ても問題ありません)
  2. インスタンスはまだ作成されていません (通常、Azure で作成するには多くの時間がかかります)
  3. ファイアウォール (Windows ファイアウォールを含む) の問題に直面している

コマンド プロンプトを使用して redis キャッシュ インスタンスに接続できますか?

ここからWindows用のredisをダウンロード

そして実行します

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

ここで詳細なデモを見つけることができます (スペイン語ですが、コンソールのデモは引き続き使用できます)。

NinjaTip #18 - Redis の紹介

テスト目的で、Redis サービスでポート 6379 が開いていることを確認します (これは Azure で有効にする必要がある非 SSL ポート オプションです)。

インスタンスに接続できない場合は、上記の理由のいくつかが原因です。

于 2015-12-10T00:37:50.137 に答える
2

以前に同じ問題があり、別の問題を使用する解決策を見つけました: https://github.com/alex-simonov/RedisAspNetProviders

これは私のために働く

于 2015-12-29T03:52:31.400 に答える