Kafka console producer throwing an error

Hi All,

I am trying to run kafka-console producer and getting below error. I got struck up here and could any one please help me to resolve this issue.

kafka-console-producer.sh --broker-list nn02.itversity.com:6667 --topic kafkaq

Error Details

[2017-05-16 15:38:08,636] WARN Error while fetching metadata with correlation id 0 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:08,732] WARN Error while fetching metadata with correlation id 1 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:08,836] WARN Error while fetching metadata with correlation id 2 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:08,940] WARN Error while fetching metadata with correlation id 3 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:09,045] WARN Error while fetching metadata with correlation id 4 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:09,149] WARN Error while fetching metadata with correlation id 5 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:09,254] WARN Error while fetching metadata with correlation id 6 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:09,359] WARN Error while fetching metadata with correlation id 7 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2017-05-16 15:38:09,462] WARN Error while fetching metadata with correlation id 8 : {kafkaq=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

Try this instead - kafka-console-producer.sh --broker-list nn01.itversity.com:6667,nn02.itversity.com:6667,rm01.itversity.com:6667 --topic kafkaq

Even though we have multiple brokers, only one will be leader. The leader might change overtime. So make sure to pass all ips of all 3 brokers all the time.

@BaLu_SaI, FYI

Thank you for your response and now I am getting different error as below. Can you please suggest what I have to do. FYI, I am using itversity LABs.

ERROR Error when sending message to topic kafkaq with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallb
ack)
org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for kafkaq-0

Dear Itversity,

I tried as you mentioned above but am receiving error as below

kafka-console-producer.sh --broker-list nn01.itversity.com:6667,nn02.itversity.com:6667,rm01.itversity.com:6667
–topic venkatkafka
hi
he[2017-05-18 11:15:47,889] ERROR Error when sending message to topic venkatkafka with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for venkatkafka-0
llo
[2017-05-18 11:15:58,310] ERROR Error when sending message to topic venkatkafka with key: null, value: 5 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for venkatkafka-0
welcome
[2017-05-18 11:16:19,046] ERROR Error when sending message to topic venkatkafka with key: null, value: 7 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for venkatkafka-0

Try now. It is working fine for me.
If the error persists create new topic and retry producing messages to it.