2
votes

I have kafka and zookeeper running in a standalone mode on an ec2 instance. I have a topic named dev_spark1 created on it. But when I am trying to run consumer from command line, gives me following error for command:

./bin/kafka-console-consumer.sh --zookeeper 172.31.8.226:9092 --topic dev_spark1

  Exception in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
        at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:880)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
        at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:171)
        at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:126)
        at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:143)
        at kafka.consumer.Consumer$.create(ConsumerConnector.scala:94)
        at kafka.tools.ConsoleConsumer$.main(ConsoleConsumer.scala:145)
        at kafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala)
1
try increasing zookeeper connection timeout property and checkmbaxi
Which version of kafka do you use? Also can you add DEBUG level for your logs?Maximilien Belinga
I have kafka_2.10-0.8.2.1 . And I have increased the zookeeper connection timeout to 60000 from 6000 in properties file but it doesnt reflect.anuja Mandlecha

1 Answers

1
votes

Are you sure that the zookeeper server is accessible from the machine where you have kafka ?

Normally zookeeper listens on port 2181 and kafka listens on port 9092. In your command your trying to connect to zookeeper on 172.31.8.226 on port 9092, is that correct.

Other way to figure this out is there is, run this command on your zookeeper machine first then on the kafka machine and check if you can connect and try out zookeeper.

bin/zookeeper-shell.sh --zookeeper 172.31.8.226:9092

If you have ability to run UI, you can use ZooInspector