{"record":{"id":"725d56910e8da880","repo":"redis/jedis","slug":"lost-connection-to-sentinel-sleeping-ms-and","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/providers/SentineledConnectionProvider.java","lineNumber":386,"sourceCode":"                  initMaster(toHostAndPort(switchMasterMsg[3], switchMasterMsg[4]));\n                } else {\n                  LOG.debug(\"Ignoring message on +switch-master for master {}. Our master is {}.\",\n                    switchMasterMsg[0], masterName);\n                }\n\n              } else {\n                LOG.error(\"Invalid message received on sentinel {} on channel +switch-master: {}.\",\n                  node, message);\n              }\n            }\n          }, \"+switch-master\");\n\n        } catch (JedisException e) {\n\n          if (running.get()) {\n            long subscribeRetryWaitTimeMillis = resubscribeDelay.delay(subscribeAttempt).toMillis();\n            subscribeAttempt++;\n            LOG.warn(\"Lost connection to Sentinel {}. Sleeping {}ms and retrying.\", node,\n              subscribeRetryWaitTimeMillis, e);\n            try {\n              sleeper.sleep(subscribeRetryWaitTimeMillis);\n            } catch (InterruptedException se) {\n              LOG.error(\"Sleep interrupted.\", se);\n            }\n          } else {\n            LOG.debug(\"Unsubscribing from sentinel {}.\", node);\n          }\n        } finally {\n          IOUtils.closeQuietly(sentinelJedis);\n        }\n      }\n    }\n\n    // must not throw exception\n    public void shutdown() {\n      try {","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/providers/SentineledConnectionProvider.java#L368-L404","documentation":"This warning is logged by the Sentinel master/replica subscription task in SentineledConnectionProvider when the pub/sub connection to a Sentinel node is lost. Rather than failing the client, the provider logs the node and a computed backoff delay, sleeps, and retries resubscribing to that Sentinel. It is a recovery-path log, not an exception thrown to the caller; the underlying JedisException is attached to the log record.","triggerScenarios":"A Sentinel node drops the pub/sub subscription: Sentinel restart, network interruption, Sentinel-side client-output-buffer limit exceeded, Sentinel failover/switchover, or idle connection timeout while the resubscribe thread is running.","commonSituations":"Flaky network between client and Sentinel quorum; Sentinel instances restarted by ops; long-running services that survive transient Sentinel outages; misconfigured Sentinel output-buffer limits (client-output-buffer-limit pubsub) killing slow subscribers.","solutions":["No code change needed if clients recover — this is expected resilience logging; verify the retry succeeds in subsequent logs.","Check connectivity/latency to the Sentinel nodes (host/port list, firewall, DNS).","Increase Sentinel's client-output-buffer-limit for pubsub if subscribers are being dropped.","Verify the sleeper/resubscribeDelay settings so retries back off appropriately for your environment.","Inspect the attached JedisException in the log for the root cause (connection refused vs reset vs timeout)."],"exampleFix":"// before: assuming any Sentinel log means an outage\n// after: correlate with node identity and check subsequent successful resubscription\nLOG.warn(\"Lost connection to Sentinel {}. Sleeping {}ms and retrying.\", node,\n  subscribeRetryWaitTimeMillis, e); // library-side; users should monitor, not fix","handlingStrategy":"retry","validationCode":"// check Sentinel reachability before building the client\nfor (HostAndPort hp : sentinels) {\n  try (Jedis s = new Jedis(hp)) { s.ping(); } // throws if node unreachable\n}","typeGuard":null,"tryCatchPattern":"// library retries internally; for your own sentinel lookups:\ntry {\n  hostPort = client.sentinelResolve(...);\n} catch (JedisConnectionException e) {\n  sleep(exponentialBackoff(attempt)); // then retry\n}","preventionTips":["Monitor Sentinel node health and quorum independently of the app","Set generous pubsub client-output-buffer limits on Sentinel","Ensure all listed Sentinel nodes are reachable (firewall/DNS checks)","Alert on repeated 'Lost connection to Sentinel' warnings rather than ignoring them"],"tags":["redis","sentinel","pubsub","reconnect","logging"],"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"}