Kafka Hello World Program is failing

I created some topics in the kafka.

[hadoopdataanalyst@gw01 kafka-broker]$ bin/kafka-topics.sh --list --zookeeper nn01.itversity.com:2181
__consumer_offsets
mysimpletopic
mysimpletopic1
mysimpletopicpart3
test
test_part
testtopic
truck_events

I opened two web consoles. One for Producer and the other for Consumer.

On the Producer console I have given the below command:

bin/kafka-console-producer.sh --broker-list nn01.itversity.com:9092 --topic mysimpletopic

On the Consumer console, I have given the below command:

bin/kafka-console-consumer.sh --zookeeper nn01.itversity.com:8121 --topic mysimpletopic --
from-beginning

Consumer console errored out by saying:

2017-01-04 22:08:21,132] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
(org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)

Where as producer console errored out with :slight_smile:

[2017-01-04 22:09:10,926] ERROR Error when sending message to topic mysimpletopic with key: null, value: 2 bytes with error: (or
g.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

Before I post this thread, I tried to do the samething in my sandbox and saw similar issue and changed the Kafka > Configs > Kafka Broker > Listeners Property

FROM -> PLAINTEXT://localhost:6667
TO -> PLAINTEXT://localhost:9092

Then I am able to run the producer and consumer without any error.

is it the same issue here?

I also tried

bin/kafka-console-producer.sh --broker-list nn01.itversity.com:6667 --topic mysimpletopic

but of no use.

Can you please help me in understanding the issue?

are you sure you are hitting the right broker?? I think i can help you.

Karthik,

if you have the access to the lab, please try to execute the code that I posted in my earlier post.

Let me know if you need more info.

Many thanks.

-Krish.

@hadoopdataanalyst
No I don’t use itversity lab.

Is the zookeeper running? And make sure you are using correct broker Id and port number while sending messages.

Thanks Karthik. Somehow it started working…!!

i think you have restarted zookeeper and kafka server.
As your error is clearly saying:
[2017-01-04 22:09:10,926] ERROR Error when sending message to topic mysimpletopic with key: null, value: 2 bytes with error: (or
g.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
“TimeoutException”.
try to run jps before running kafka producer or consumer

Unfortunately, I do not have admin rights to start/stop the service.

why you need admin rights? to run jps

Hi @Krish_Kilaru, are you able to run the consumer on labs.itversity without any error? Can you share which command you have used for it.

Thanks