Namoshek / laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.
MIT License
17 stars 14 forks source link

PHP Fatal error: Uncaught ValueError: Invalid port in /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php:120 #33

Open LyKos4 opened 2 months ago

LyKos4 commented 2 months ago

Below error has been generated

PHP Fatal error: Uncaught ValueError: Invalid port in /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php:120 Stack trace:

0 /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php(120): RedisSentinel->__construct(Array)

1 /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php(57): Namoshek\Redis\Sentinel\Connectors\PhpRedisSentinelConnector->connectToSentinel(Array)

2 /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php(32): Namoshek\Redis\Sentinel\Connectors\PhpRedisSentinelConnector->createClient(Array)

3 /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php(36): Namoshek\Redis\Sentinel\Connectors\PhpRedisSentinelConnector->Namoshek\Redis\Sentinel\Connectors{closure}()

4 /application/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(112): Namoshek\Redis\Sentinel\Connectors\PhpRedisSentinelConnector->connect(Array, Array)

5 /application/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(91): Illuminate\Redis\RedisManager->resolve('cache')

6 /application/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(262): Illuminate\Redis\RedisManager->connection('cache')

7 /application/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(62): Illuminate\Cache\RedisStore->connection()

8 /application/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(99): Illuminate\Cache\RedisStore->get('sentry_rate_lim...')

9 /application/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php(139): Illuminate\Cache\Repository->get('sentry_rate_lim...', 0)

10 /application/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php(92): Illuminate\Cache\RateLimiter->attempts('sentry_rate_lim...')

11 /application/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php(74): Illuminate\Cache\RateLimiter->tooManyAttempts('sentry_rate_lim...', 100)

12 /application/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(338): Illuminate\Cache\RateLimiter->attempt('sentry_rate_lim...', 100, Object(Closure), 60)

13 /application/app/Exceptions/Handler.php(79): Illuminate\Support\Facades\Facade::__callStatic('attempt', Array)

14 [internal function]: App\Exceptions\Handler->App\Exceptions{closure}(Object(Symfony\Component\ErrorHandler\Error\FatalError))

15 /application/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/ReportableHandler.php(45): call_user_func(Object(Closure), Object(Symfony\Component\ErrorHandler\Error\FatalError))

16 /application/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(256): Illuminate\Foundation\Exceptions\ReportableHandler->__invoke(Object(Symfony\Component\ErrorHandler\Error\FatalError))

17 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(198): Illuminate\Foundation\Exceptions\Handler->report(Object(Symfony\Component\ErrorHandler\Error\FatalError))

18 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(246): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Symfony\Component\ErrorHandler\Error\FatalError))

19 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(270): Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()

20 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap{closure}()

21 {main}

thrown in /application/vendor/namoshek/laravel-redis-sentinel/src/Connectors/PhpRedisSentinelConnector.php on line 120

with settings REDIS_SENTINEL_HOST: sentinel.redis-sentinel.svc.cluster.local:26379 (tried with and without port) REDIS_SENTINEL_PORT: "26379"

where sentinel is a service with port 26379 in namespace redis-sentinel defined in kubernetes cluster.

Any ideas why there is an issue with the port settings?

Namoshek commented 2 months ago

My only idea is that there is an issue with the type of the port, e.g. that it is passed as string instead of an integer. Maybe cast the value in the config?

'sentinel_port' => (int) env('REDIS_SENTINEL_PORT', 26379),