{"record":{"id":"86770ba6d27fed76","repo":"apache/dolphinscheduler","slug":"cannot-connect-to-registry-in-s-s","errorCode":null,"errorMessage":"Cannot connect to registry in %s s","messagePattern":"Cannot connect to registry in (.+?) s","errorType":"exception","errorClass":"RegistryException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java","lineNumber":129,"sourceCode":"            }\n            stopWatch.stop();\n            log.info(\"ZookeeperRegistry started at: {}/ms\", stopWatch.getTime());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new RegistryException(\"Zookeeper registry start failed\", e);\n        }\n    }\n\n    @Override\n    public void addConnectionStateListener(ConnectionListener listener) {\n        client.getConnectionStateListenable().addListener(new ZookeeperConnectionStateListener(listener));\n    }\n\n    @Override\n    public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryException {\n        try {\n            if (!client.blockUntilConnected(DurationUtils.toMillisInt(timeout), MILLISECONDS)) {\n                throw new RegistryException(\n                        String.format(\"Cannot connect to registry in %s s\", timeout.getSeconds()));\n            }\n        } catch (RegistryException e) {\n            throw e;\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new RegistryException(\n                    String.format(\"Cannot connect to registry in %s s\", timeout.getSeconds()), e);\n        }\n    }\n\n    @Override\n    public void subscribe(final String path, final SubscribeListener listener) {\n        final TreeCache treeCache = treeCacheMap.computeIfAbsent(path, $ -> new TreeCache(client, path));\n        treeCache.getListenable().addListener(new ZookeeperTreeCacheListenerAdapter(path, listener));\n        try {\n            treeCache.start();\n        } catch (Exception e) {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java#L111-L147","documentation":"Thrown by ZookeeperRegistry.connectUntilTimeout(Duration) when the Curator client is still not connected after the given timeout elapses. The message contains the timeout in seconds. The original RegistryException is rethrown as-is; no cause is attached in this branch.","triggerScenarios":"Calling connectUntilTimeout(timeout) on a registry whose Curator client cannot reach the ZooKeeper ensemble within that duration (servers down, wrong connect string, network partition).","commonSituations":"ZooKeeper quorum unavailable at startup; misconfigured connect string after environment migration; slow network or overloaded ensemble exceeding a short timeout; startup sequencing expecting a sidecar not yet ready.","solutions":["Verify ZooKeeper connectivity (host:port) and that the ensemble is serving","Increase the timeout passed to connectUntilTimeout","Add connection-state listeners and retry logic with backoff around connectUntilTimeout","Check network/DNS/firewall between client and ensemble","Ensure the client was start()-ed before waiting on connectUntilTimeout"],"exampleFix":"// before\nregistry.connectUntilTimeout(Duration.ofSeconds(5));\n// after\nregistry.connectUntilTimeout(Duration.ofSeconds(60));","handlingStrategy":"try-catch","validationCode":"if (!zookeeperReachable(connectString)) {\n    throw new IllegalStateException(\"ZooKeeper unreachable, skipping connectUntilTimeout\");\n}","typeGuard":"boolean zookeeperReachable(String connectString) {\n    return Arrays.stream(connectString.split(\",\"))\n        .allMatch(hp -> {\n            String[] p = hp.trim().split(\":\");\n            try (Socket s = new Socket()) {\n                s.connect(new InetSocketAddress(p[0], Integer.parseInt(p[1])), 3000);\n                return true;\n            } catch (IOException e) { return false; }\n        });\n}","tryCatchPattern":"try {\n    registry.connectUntilTimeout(Duration.ofSeconds(60));\n} catch (RegistryException e) {\n    log.error(\"ZooKeeper not connected within timeout\");\n    // retry with backoff or fail fast\n}","preventionTips":["Pass a realistic timeout for your network, not a small default","Ensure client.start() was called before waiting to connect","Add a connection-state listener to detect/retry disconnects","Verify ensemble health and quorum before application startup"],"tags":["zookeeper","timeout","connectivity","startup"],"backgroundTag":"request-timeout","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}