使用以下代碼報(bào)錯(cuò),執(zhí)行的業(yè)務(wù)邏輯是采集任務(wù),有時(shí)候會(huì)重試時(shí)間稍長(zhǎng),偶發(fā)性出現(xiàn)Redis超時(shí),之后就會(huì)出現(xiàn)一直連不上,請(qǐng)教一下該怎么解決,謝謝
$worker = new Worker();
$worker->count = 10;
$worker->onWorkerStart = function($worker)
{
$redisOptions = [
'db'=>2,
'wait_timeout' => '0',
'max_attempts' => '10',
'retry_seconds' => '10',
'wait_timeout' => '600000',
];
$client = new Client('redis://127.0.0.1:6379',$redisOptions);
$client->subscribe('task-eBay-item', function($data){
//執(zhí)行業(yè)務(wù)邏輯
});
};
Warning: Invalid argument supplied for foreach() in /vendor/workerman/redis-queue/src/Client.php on line 177
Exception: Workerman Redis Connection Error 2 client closed in /vendor/workerman/redis/src/Client.php:346
Stack trace:
#0 /vendor/workerman/workerman/Connection/TcpConnection.php(370): Workerman\Redis\Client->Workerman\Redis\{closure}(Object(Workerman\Connection\AsyncTcpConnection), 2, 'client closed')
#1 /vendor/workerman/redis/src/Client.php(461): Workerman\Connection\TcpConnection->send('*4\r\n$4\r\nZADD\r\n$...')
#2 /vendor/workerman/redis/src/Client.php(423): Workerman\Redis\Client->process()
#3 /vendor/workerman/workerman/Connection/TcpConnection.php(637): Workerman\Redis\Client->Workerman\Redis\{closure}(Object(Workerman\Connection\AsyncTcpConnection), Array)
#4 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #52, 2, Resource id #52)
#5 /vendor/workerman/workerman/Events/Event.php(195): EventBase->loop()
#6 /vendor/workerman/workerman/Worker.php(2430): Workerman\Events\Event->loop()
#7 /vendor/workerman/workerman/Worker.php(1554): Workerman\Worker->run()
#8 /vendor/workerman/workerman/Worker.php(1384): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#9 /vendor/workerman/workerman/Worker.php(1358): Workerman\Worker::forkWorkersForLinux()
#10 /vendor/workerman/workerman/Worker.php(542): Workerman\Worker::forkWorkers()
#11 /task-item.php(129): Workerman\Worker::runAll()
#12 {main}Workerman Redis Connection to redis://127.0.0.1:6379 timeout (5 seconds)
Workerman Redis Connection to redis://127.0.0.1:6379 timeout (5 seconds)
Workerman Redis Connection to redis://127.0.0.1:6379 timeout (5 seconds)
Workerman Redis Connection to redis://127.0.0.1:6379 timeout (5 seconds)
Workerman Redis Connection to redis://127.0.0.1:6379 timeout (5 seconds)