Loading

Hyperf async-queue 队列 [ERROR] RedisException: read error on connection to xxx in /opt/www/vendor/hyperf/redis/src/RedisConnection.php:211

起因:在redis异步队列中 总是有很多超时的任务,于是将redis-queue的任务超时时间调整到了3600
async_queue.php

'default' => [
      'driver' => \Hyperf\AsyncQueue\Driver\RedisDriver::class,
      'redis' => [
          'pool' => 'default',
      ],
      'channel' => env('QUEUE_CHANNEL', 'queue'),
      'timeout' => 3600,
      'retry_seconds' => [5, 10, 20, 30, 60],
      'handle_timeout' => 3600,
      'processes' => 1,
      'concurrent' => [
          'limit' => 10,
      ],
]

于是启动后每当执行队列时都会报

[WARNING] Redis::__call failed, because read error on connection to host.docker.internal:6379
[WARNING] Redis::__call failed, because read error on connection to host.docker.internal:6379        
[INFO] Crontab task [xxxTask] executed successfully at 2024-12-31 12:28:00.
[ERROR] RedisException: read error on connection to host.docker.internal:6379 in /opt/www/vendor/hyperf/redis/src/RedisConnection.php:211
Stack trace:
#0 /opt/www/vendor/hyperf/redis/src/RedisConnection.php(211): Redis->brPop()
#1 /opt/www/vendor/hyperf/redis/src/RedisConnection.php(84): Hyperf\Redis\RedisConnection->retry()   
#2 /opt/www/vendor/hyperf/redis/src/Redis.php(43): Hyperf\Redis\RedisConnection->__call()
#3 /opt/www/vendor/hyperf/async-queue/src/Driver/RedisDriver.php(83): Hyperf\Redis\Redis->__call()   
#4 /opt/www/vendor/hyperf/async-queue/src/Driver/Driver.php(62): Hyperf\AsyncQueue\Driver\RedisDriver->pop()
#5 /opt/www/vendor/hyperf/async-queue/src/Process/ConsumerProcess.php(42): Hyperf\AsyncQueue\Driver\Driver->consume()
#6 /opt/www/vendor/hyperf/process/src/AbstractProcess.php(99): Hyperf\AsyncQueue\Process\ConsumerProcess->handle()
#7 [internal function]: Hyperf\Process\AbstractProcess->Hyperf\Process\{closure}()
#8 {main}

仔细研究后发现

'timeout' => 3600
这个配置的含义是 等待pop消息的时间 ,如果设置的太大会导致 “ read error on connection ” 的报错
于是将该参数调整回
'timeout' => 5
完美解决

posted @ 2024-12-31 15:43  ZJH_BLOGS  阅读(181)  评论(0)    收藏  举报