Skip to content

Commit 9ec9dad

Browse files
sam-tang-swkkdaysamtangtaylorotwell
authored
[9.x] Reconnect when redis throw read error exception (#41670)
* reconnect when redis throw read error exception * Update PhpRedisConnection.php * Update PhpRedisConnection.php Co-authored-by: kkdaysamtang <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 5c919df commit 9ec9dad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Illuminate/Redis/Connections/PhpRedisConnection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,12 @@ public function command($method, array $parameters = [])
531531
try {
532532
return parent::command($method, $parameters);
533533
} catch (RedisException $e) {
534-
if (str_contains($e->getMessage(), 'went away') || str_contains($e->getMessage(), 'socket')) {
535-
$this->client = $this->connector ? call_user_func($this->connector) : $this->client;
534+
foreach (['went away', 'socket', 'read error on connection'] as $errorMessage) {
535+
if (str_contains($e->getMessage(), $errorMessage)) {
536+
$this->client = $this->connector ? call_user_func($this->connector) : $this->client;
537+
538+
break;
539+
}
536540
}
537541

538542
throw $e;

0 commit comments

Comments
 (0)