【问题标题】:redis timeout with predisredis 超时与 predis
【发布时间】:2023-04-03 18:22:01
【问题描述】:

我正在使用带有 php 的 redis(predis 在http://github.com/nrk/predis/)并且经常遇到超时。堆栈跟踪显示:

[04-Apr-2010 03:39:50] PHP Fatal error:  Uncaught exception 'Predis_ClientException' with message 'Connection timed out' in redis.php:697
Stack trace:
#0 redis.php(757): Predis_Connection->connect()
#1 redis.php(729): Predis_Connection->getSocket()
#2 redis.php(825): Predis_Connection->writeCommand(Object(Predis_Commands_ListRange))
#3 redis.php(165): Predis_ConnectionCluster->writeCommand(Object(Predis_Commands_ListRange))
#4 redis.php(173): Predis_Client->executeCommandInternal(Object(Predis_ConnectionCluster), Object(Predis_Commands_ListRange))
#5 redis.php(157): Predis_Client->executeCommand(Object(Predis_Commands_ListRange))
#6 [internal function]: Predis_Client->__call('lrange', Array)

这种情况一直发生,我不知道为什么。有人知道吗?

【问题讨论】:

    标签: redis predis


    【解决方案1】:

    我认为这是因为 Redis 默认关闭空闲连接。

    redis.conf

    # Close the connection after a client is idle for N seconds (0 to disable)
    timeout 0
    

    【讨论】:

    • 在达到允许的最大连接数之前的几秒钟后,空闲连接是否应该关闭?
    • 0 表示禁用超时,默认情况下它设置为 0...所以这不应该是超时问题,但正如下面@SuneRievers 所述,该功能存在错误。
    【解决方案2】:

    Redis Issues List 上有一个未确认错误,请尝试将 Redis 更新到最新版本,看看问题是否仍然存在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 2013-09-30
      • 2017-09-18
      • 2017-04-26
      • 2014-07-13
      相关资源
      最近更新 更多