swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 785 forks source link

Redis的readTimeout配置项与描述不符 #1421

Open GraciousVertex32 opened 3 years ago

GraciousVertex32 commented 3 years ago
Q A
Bug report? yes
Feature request? no
Swoft version 2.0.10
Swoole version 4.6.4
PHP version 7.4.3
Runtime environment Win10 WSL2 Ubuntu20.04

Describe the bug Redis的readTimeout配置项设为0时候实际仍为60,不能永不超时

Expected behavior readTimeout为0时不会出现连接错误

Screenshots image

Details 配置bean.php中Redis的readTimeout = 0, 新建用户进程, 用户进程设置default_socket_timeout为-1, 用户进程redis订阅频道后,如果没有发布消息,2分钟种后会出现read error on connection错误,用户进程被拉起后2分钟仍会出现此错误

配置readTimeout = 10, 用户进程设置default_socket_timeout为-1, 20秒后会出现read error on connection错误,检查源码推断20秒是因为框架在连接出错后会自动重连一次

配置readTimeout = 65, 用户进程设置default_socket_timeout为-1, 2分10秒后会出现read error on connection错误

配置readTimeout = 0, 用户进程设置default_socket_timeout为10, 2分钟后会出现read error on connection错误

配置readTimeout = 0, 用户进程设置default_socket_timeout为90, 2分钟后会出现read error on connection错误

删除readTimeout配置, 用户进程设置default_socket_timeout为-1, 2分钟后会出现read error on connection错误

用户进程

/**
 * Class TestLogic
 *
 * @since 2.0
 *
 * @Bean()
 */
class TestLogic
{
    public function test(Process $process): void
    {
        $process->name('test-process');
        while (true) {
            ini_set('default_socket_timeout', -1);
            $new = ini_get('default_socket_timeout');
            Clog::info("update default_socket_timeout,new:{$new}");
            Redis::subscribe(["logout"],function ($redis, $chan, $msg) {
                switch($chan) {
                    case 'logout':
                        echo 'get published'.PHP_EOL;
                        break;
                }
            });
        }
    }
}

报错

 [ERROR] User process fail(/mnt/f/softs/h5games/dining-hall-swoft/vendor/swoft/redis/src/Connection/Connection.php Redis command reconnect error=read error on connection to 127.0.0.1:6379 271)!
XuanYi2018 commented 3 years ago

好的,多谢反馈,我们最近找时间修复下这个bug。