From ff57e7ae9753b3540d93995c9369ade6e9bdc548 Mon Sep 17 00:00:00 2001 From: Sean Dean <254259913+distronode-com@users.noreply.github.com> Date: Sun, 23 Aug 2026 20:30:37 -0400 Subject: [PATCH] redis: honour dial/read/write timeouts in all modes, not just Sentinel RedisConfig exposes dial_timeout, read_timeout and write_timeout, but GetRedisClient only reads them in the Sentinel branch. A single-address or cluster deployment can set them and they are silently ignored -- nothing errors and nothing warns. Pass them through in all three branches. Sentinel keeps its existing 2000/200/200 defaults; the other two leave an unset value at zero so go-redis applies its own defaults, so a config that does not set them behaves exactly as before. Co-Authored-By: Claude Opus 5 (1M context) --- .changeset/redis-timeouts-all-modes.md | 5 +++++ redis/redis.go | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 .changeset/redis-timeouts-all-modes.md diff --git a/.changeset/redis-timeouts-all-modes.md b/.changeset/redis-timeouts-all-modes.md new file mode 100644 index 000000000..77a6197c9 --- /dev/null +++ b/.changeset/redis-timeouts-all-modes.md @@ -0,0 +1,5 @@ +--- +"github.com/livekit/protocol": patch +--- + +Honour `dial_timeout`, `read_timeout` and `write_timeout` for single-address and cluster Redis, not just Sentinel. They were previously accepted by `RedisConfig` but only ever read in the Sentinel branch, so setting them on any other deployment silently did nothing. diff --git a/redis/redis.go b/redis/redis.go index 6881ba1d0..15b531a8c 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -137,6 +137,9 @@ func GetRedisClient(conf *RedisConfig) (redis.UniversalClient, error) { DB: conf.DB, TLSConfig: tlsConfig, MaxRedirects: conf.GetMaxRedirects(), + DialTimeout: time.Duration(conf.DialTimeout) * time.Millisecond, + ReadTimeout: time.Duration(conf.ReadTimeout) * time.Millisecond, + WriteTimeout: time.Duration(conf.WriteTimeout) * time.Millisecond, PoolTimeout: conf.PoolTimeout, PoolSize: conf.PoolSize, IsClusterMode: true, @@ -144,13 +147,16 @@ func GetRedisClient(conf *RedisConfig) (redis.UniversalClient, error) { } else { logger.Infow("connecting to redis", "simple", true, "addr", conf.Address) rcOptions = &redis.UniversalOptions{ - Addrs: []string{conf.Address}, - Username: conf.Username, - Password: conf.Password, - DB: conf.DB, - TLSConfig: tlsConfig, - PoolTimeout: conf.PoolTimeout, - PoolSize: conf.PoolSize, + Addrs: []string{conf.Address}, + Username: conf.Username, + Password: conf.Password, + DB: conf.DB, + TLSConfig: tlsConfig, + DialTimeout: time.Duration(conf.DialTimeout) * time.Millisecond, + ReadTimeout: time.Duration(conf.ReadTimeout) * time.Millisecond, + WriteTimeout: time.Duration(conf.WriteTimeout) * time.Millisecond, + PoolTimeout: conf.PoolTimeout, + PoolSize: conf.PoolSize, } } rc = redis.NewUniversalClient(rcOptions)