没有可用于此操作的连接:ZRANGEBYSCORE redis

时间:2017-11-23 03:24:27

标签: c# asp.net-core stackexchange.redis

我总是得到这个错误

asp.net core 2.0

StackExchange.Redis.StrongName 1.2.6

3 redis server 1 master 2 replica

仅从副本读取并写入主人

像这样初始化连接管理器


 public  static class X
    {
        static string connectionString;

        public static void InitializeConnectionString(string cnxString)
        {
            if (string.IsNullOrWhiteSpace(cnxString))
                throw new ArgumentNullException(nameof(cnxString));

            connectionString = cnxString;
        }

        private static readonly Lazy LazyConnection = new Lazy(() =>
        {
            var connection = ConnectionMultiplexer.Connect(connectionString);
            connection.PreserveAsyncOrder = false;
            return connection;

        });

        public static ConnectionMultiplexer SafeCoonect
        {
            get
            {
                return LazyConnection.Value;
            }
        }
      }

enter image description here

  

StackExchange.Redis.RedisConnectionException:没有连接   可用于此操作:ZRANGEBYSCORE   XXXXX:day20171122:XXXX;无法连接到redis   服务器(一个或多个); ConnectTimeout ---> System.AggregateException:一个或多个   发生了错误。 (无法连接到redis   服务器(一个或多个); ConnectTimeout)(无法连接到   redis服务器; ConnectTimeout)(无法连接到   redis服务器; ConnectTimeout)(无法连接   到redis服务器; ConnectTimeout)--->   StackExchange.Redis.RedisConnectionException:这是不可能的   连接到redis服务器; ConnectTimeout ---内心的结束   异常堆栈跟踪--- ---内部异常堆栈跟踪结束---   在   StackExchange.Redis.ConnectionMultiplexer.ThrowFailed [T](TaskCompletionSource`1   source,Exception unthrownException)in   X:\代码\ StackExchange.Redis \ StackExchange.Redis \ StackExchange \ Redis的\ ConnectionMultiplexer.cs:线   2000 ---从异常的先前位置开始的堆栈跟踪结束   扔了 - 在   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在y.d__12.MoveNext()在x:\ x.cs:第163行---堆栈跟踪结束   从之前的位置抛出异常---在   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在y.d__8.MoveNext()在x:\ x.cs:第70行---堆栈跟踪结束   从之前的位置抛出异常---在   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在z.d__14.MoveNext()中z:\ z \ z.cs:第113行---栈尾   从抛出异常的先前位置追踪--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在lambda_method(Closure,Object)at   Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()   在   Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext   上下文)   Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(州及放大器;   接下来,范围&范围,对象& state,Boolean& isCompleted)at   Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__14.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__22.MoveNext()---   从抛出异常的先前位置开始的堆栈跟踪结束   ---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext   上下文)   Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next,   适用范围和放大器;范围,对象& state,Boolean& isCompleted)at   Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__17.MoveNext()---   从抛出异常的先前位置开始的堆栈跟踪结束   ---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__15.MoveNext()---   从抛出异常的先前位置开始的堆栈跟踪结束   ---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.d__2.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.d__2.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.d__2.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d__6.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   Microsoft.AspNetCore.Session.SessionMiddleware.d__9.MoveNext()---结束   抛出异常的先前位置的堆栈跟踪---   在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   Microsoft.AspNetCore.Session.SessionMiddleware.d__9.MoveNext()---结束   抛出异常的先前位置的堆栈跟踪---   在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)在Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()

1 个答案:

答案 0 :(得分:0)

此帖子有些陈旧,但以防其他人碰到它。 Github问题,将其列为版本2.X中的固定版本

https://github.com/StackExchange/StackExchange.Redis/issues/871

871还列出了上述stackexchange问​​题 https://github.com/StackExchange/StackExchange.Redis/issues/743