{"record":{"id":"c8278b19a303166f","repo":"redis/jedis","slug":"lost-connection-to-sentinel-sleeping-ms-a","errorCode":null,"errorMessage":"Lost connection to Sentinel {}:{}. Sleeping {}ms and retrying.","messagePattern":"Lost connection to Sentinel (.+?):(.+?)\\. Sleeping (.+?)ms and retrying\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/java/redis/clients/jedis/JedisSentinelPool.java","lineNumber":420,"sourceCode":"                if (masterName.equals(switchMasterMsg[0])) {\n                  initMaster(toHostAndPort(Arrays.asList(switchMasterMsg[3], switchMasterMsg[4])));\n                } else {\n                  LOG.debug(\n                    \"Ignoring message on +switch-master for master name {}, our master name is {}\",\n                    switchMasterMsg[0], masterName);\n                }\n\n              } else {\n                LOG.error(\"Invalid message received on Sentinel {} on channel +switch-master: {}\",\n                    hostPort, message);\n              }\n            }\n          }, \"+switch-master\");\n\n        } catch (JedisException e) {\n\n          if (running.get()) {\n            LOG.warn(\"Lost connection to Sentinel {}:{}. Sleeping {}ms and retrying.\", host, port, subscribeRetryWaitTimeMillis,\n                    e);\n            try {\n              Thread.sleep(subscribeRetryWaitTimeMillis);\n            } catch (InterruptedException e1) {\n              LOG.error(\"Sleep interrupted: \", e1);\n            }\n          } else {\n            LOG.debug(\"Unsubscribing from Sentinel at {}:{}\", host, port);\n          }\n        } finally {\n          if (j != null) {\n            j.close();\n          }\n        }\n      }\n    }\n\n    public void shutdown() {","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/JedisSentinelPool.java#L402-L438","documentation":"MasterListener subscribes to Sentinel pub/sub channels; if the subscription or its connection raises JedisException (Sentinel unreachable, connection reset, timeout) while the thread is still running, this warning is logged and the thread sleeps subscribeRetryWaitTimeMillis before retrying. The client keeps attempting indefinitely — this is the expected log when a Sentinel becomes temporarily unavailable after startup.","triggerScenarios":"In MasterListener.run: the `new Jedis(hostPort, sentinelClientConfig)` connection or `j.subscribe(...)` throws JedisException — Sentinel process down, network drop, Sentinel restarted, connection evicted by a proxy/LB idle timeout.","commonSituations":"Sentinel host rebooted or OOM-killed; client runs in a different DC and long-lived pub/sub connections are dropped by stateful firewalls; Sentinel port blocked after network policy change; frequent warnings flooding logs during a Sentinel outage.","solutions":["Restore connectivity to the Sentinel at host:port named in the warning (ping it on 26379); the thread will reconnect automatically.","If the Sentinel is permanently removed, restart the client with an updated sentinel set.","Increase subscribeRetryWaitTimeMillis to reduce log spam/backoff pressure during known outages.","Check for LB/firewall idle timeouts killing long-lived pub/sub sockets and raise their idle limits.","Monitor Sentinels themselves — 2-of-3 Sentinel loss means failover detection is degraded."],"exampleFix":"// before\nnew JedisSentinelPool(master, sentinels, 2000 /* subscribeRetryWaitTimeMillis default-ish */);\n// after — larger retry window for flaky links\nnew JedisSentinelPool(master, sentinels, poolConfig, 60000 /* subscribeRetryWaitTimeMillis */);","handlingStrategy":"retry","validationCode":"// preflight\ntry (Jedis j = new Jedis(sentinelHost, sentinelPort)) {\n  j.ping(); // fail deployment early if sentinel unreachable\n}","typeGuard":null,"tryCatchPattern":"try { jedis.subscribe(pubSub, \"+switch-master\"); } catch (JedisException e) { if (running.get()) { Thread.sleep(subscribeRetryWaitTimeMillis); /* loop retries */ } }","preventionTips":["Monitor Sentinel liveness; this warning flood means a Sentinel is down","Tune subscribeRetryWaitTimeMillis for your network's outage profile","Raise LB/firewall idle timeouts so long-lived pub/sub sockets survive","Remove decommissioned Sentinels from the client's sentinel set"],"tags":["redis","sentinel","pubsub","network","retry"],"backgroundTag":"connection-refused","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}