{"record":{"id":"60da8c1cd0286421","repo":"t8y2/dbx","slug":"timed-out-connecting-to-zookeeper-for-kafka-broker","errorCode":null,"errorMessage":"Timed out connecting to ZooKeeper for Kafka broker discovery","messagePattern":"Timed out connecting to ZooKeeper for Kafka broker discovery","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java","lineNumber":349,"sourceCode":"        resolved.addProperty(\"bootstrap_servers\", discoverBootstrapServers(connectString, securityProtocol(conn), conn));\n        return resolved;\n    }\n\n    private static String discoverBootstrapServers(String connectString, String securityProtocol, JsonObject conn)\n        throws Exception {\n        int sessionTimeout = intOrDefault(conn, \"zookeeper_session_timeout_ms\", DEFAULT_SESSION_TIMEOUT_MS);\n        int connectionTimeout = intOrDefault(\n            conn,\n            \"zookeeper_connection_timeout_ms\",\n            DEFAULT_ZOOKEEPER_CONNECTION_TIMEOUT_MS\n        );\n        CountDownLatch connected = new CountDownLatch(1);\n        ZooKeeper zooKeeper = new ZooKeeper(connectString, sessionTimeout, event -> {\n            if (event.getState() == Watcher.Event.KeeperState.SyncConnected) connected.countDown();\n        }, zooKeeperClientConfig(conn));\n        try {\n            if (!connected.await(connectionTimeout, TimeUnit.MILLISECONDS)) {\n                throw new IllegalStateException(\"Timed out connecting to ZooKeeper for Kafka broker discovery\");\n            }\n\n            List<String> brokerIds;\n            try {\n                brokerIds = new ArrayList<>(zooKeeper.getChildren(\"/brokers/ids\", false));\n            } catch (KeeperException.NoNodeException e) {\n                throw new IllegalStateException(\"ZooKeeper path /brokers/ids does not exist\", e);\n            }\n            brokerIds.sort(KafkaAgent::compareBrokerIds);\n\n            List<JsonObject> registrations = new ArrayList<>();\n            for (String brokerId : brokerIds) {\n                try {\n                    byte[] data = zooKeeper.getData(\"/brokers/ids/\" + brokerId, false, null);\n                    registrations.add(JsonParser.parseString(new String(data, StandardCharsets.UTF_8)).getAsJsonObject());\n                } catch (KeeperException.NoNodeException e) {\n                    // Expected race: a broker may refresh its ephemeral node between list and read.\n                    logger().debug(\"Kafka broker {} disappeared during ZooKeeper discovery\", brokerId);","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java#L331-L367","documentation":"Thrown by discoverBootstrapServers when a ZooKeeper client did not reach the SyncConnected state within zookeeper_connection_timeout_ms (default DEFAULT_ZOOKEEPER_CONNECTION_TIMEOUT_MS). The ensemble is unreachable, slow, or the connect string is wrong, so broker discovery via ZooKeeper cannot proceed.","triggerScenarios":"Thrown at agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java:349 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the zookeeper_connect_string host:port entries are reachable from the agent host","Increase zookeeper_connection_timeout_ms and zookeeper_session_timeout_ms","Check network/firewall rules and ZooKeeper ensemble health (four-letter words like srvr)","If ZooKeeper is not actually fronting this Kafka cluster, configure bootstrap_servers directly instead"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}