0
votes

I am trying to setup kafka for messaging service.

I am using kafka_2.9.2-0.8.1.1 version, I have started zookeeper, kafka and created a topic with no partition and replication factor.

Once I start my consumer, I get the following error

./kafka-console-consumer.sh --zookeeper localhost:9092 --topic test --from-beginning
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:156)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:114)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:128)
    at kafka.consumer.Consumer$.create(ConsumerConnector.scala:89)
    at kafka.consumer.console Consumer$.main(ConsoleConsumer.scala:178)
    at kafka.consumer.ConsoleConsumer.main(ConsoleConsumer.scala) 

My zookeeper is running, I have ensured that by netstat command!!

Not sure what is going wrong here. Any inputs on this will be helpful

2
does your zk use the port 9092 ? try echo srvr |nc localhost 9092, check the output.sel-fish
ZooKeeper runs on port 2181 by default.vahid
try to kill ZK process and start it again. do lsof -i -n -P | grep 2181 to get the process id and then kill -9 process_idGiorgos Myrianthous
BTW: It is not possible to create a topic with 'no partition'TobiSH

2 Answers

0
votes

it should be --bootstrap-server and not --zookeeper

0
votes

I have reinstalled the latest version of kafka which solved the issue. As per above comments i have tried every thing but no luck!! I suspect the package was not downloaded properly!! I will update the answer if i get to know the exact reason for the error.