Python社区  »  Redis

redisconnectionexception:无法连接到redis服务器;connecttimeout

Prem • 4 月前 • 133 次点击  

我已经看到关于这个错误的各种问题,但找不到任何相关的解决方案。

我在用 stackexchange.redis.strong名称 程序集版本 1.2.6.0条 用于连接到 Redis服务器3.2.10版 随机面对这种重新连接的例外。 我们的架构是在aws上托管的web农场架构,有时一台机器无法连接到redis服务器,但另一台运行良好。所以这就保证了redis服务器的正常运行。另外,当一台计算机无法连接时,我们尝试使用redis-cli.exe进行连接,它工作正常,没有任何问题。

我分享以下完整的例外:

[RedisConnectionException: It was not possible to connect to the redis server(s); ConnectTimeout]

    [RedisConnectionException: No connection is available to service this operation: EVAL; It was not possible to connect to the redis server(s); ConnectTimeout; IOCP: (Busy=0,Free=1000,Min=2,Max=1000), WORKER: (Busy=767,Free=32000,Min=2,Max=32767), Local-CPU: n/a]
       StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl(Message message, ResultProcessor`1 processor, ServerEndPoint server) +4657
       StackExchange.Redis.RedisBase.ExecuteSync(Message message, ResultProcessor`1 processor, ServerEndPoint server) +122
       StackExchange.Redis.RedisDatabase.ScriptEvaluate(String script, RedisKey[] keys, RedisValue[] values, CommandFlags flags) +142
       Microsoft.Web.Redis.<>c__DisplayClass4.<Eval>b__3() +56
       Microsoft.Web.Redis.StackExchangeClientConnection.RetryForScriptNotFound(Func`1 redisOperation) +135
       Microsoft.Web.Redis.StackExchangeClientConnection.RetryLogic(Func`1 redisOperation) +144
       Microsoft.Web.Redis.StackExchangeClientConnection.Eval(String script, String[] keyArgs, Object[] valueArgs) +542
       Microsoft.Web.Redis.RedisConnectionWrapper.TryTakeWriteLockAndGetData(DateTime lockTime, Int32 lockTimeout, Object& lockId, ISessionStateItemCollection& data, Int32& sessionTimeout) +262
       Microsoft.Web.Redis.RedisSessionStateProvider.GetItemFromSessionStore(Boolean isWriteLockRequired, HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +1160
       Microsoft.Web.Redis.RedisSessionStateProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +211
       System.Web.SessionState.SessionStateModule.GetSessionStateItem() +176
       System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1018
       System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +710
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +634

下面是我用来创建到redis服务器的连接的代码

var configOptions = new StackExchange.Redis.ConfigurationOptions
{
   ConnectTimeout = 5000,
   ConnectRetry = 5,
   SyncTimeout = 5000,
   AbortOnConnectFail = false,
};

configOptions.EndPoints.Add(host, port);

var conn = StackExchange.Redis.ConnectionMultiplexer.Connect(configOptions);
return conn;

有谁能帮我找出这个问题的根本原因或一些调试步骤,也会有很大的帮助。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46879
 
133 次点击  
分享到微博