Skip to content

Commit 89f6c00

Browse files
fix:fix hyperf 2.2 version redis sentinel connect failed (#5362)
1 parent f0b858b commit 89f6c00

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/RedisConnection.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ protected function createRedisSentinel()
209209
$readTimeout = $this->config['sentinel']['read_timeout'] ?? 0;
210210
$masterName = $this->config['sentinel']['master_name'] ?? '';
211211
$auth = $this->config['sentinel']['auth'] ?? null;
212+
// fixes bug for phpredis
213+
// https://github.com/phpredis/phpredis/issues/2098
214+
$extendConfig = [];
215+
if (! empty($auth)) {
216+
$extendConfig[] = $auth;
217+
}
218+
212219
shuffle($nodes);
213220

214221
$host = null;
@@ -223,7 +230,7 @@ protected function createRedisSentinel()
223230
$persistent,
224231
$retryInterval,
225232
$readTimeout,
226-
$auth
233+
...$extendConfig
227234
);
228235
$masterInfo = $sentinel->getMasterAddrByName($masterName);
229236
if (is_array($masterInfo) && count($masterInfo) >= 2) {

0 commit comments

Comments
 (0)