I am trying to send messages using the Kafka console producer to a Kafka broker that is running on the same machine. When I run
echo "Hello world" | ./kafka-console-producer.sh --broker-list localhost:9092 --topic test
I receive the following error message:
[2016-06-29 15:00:44,069] ERROR Error when sending message to topic test with key: null, value: 11 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 test-0
When I check if the Kafka broker is listening on port 9092, it is there and running. How do I debug why cannot the command line producer connect to the broker? Thank you!
Run Kafka Producer Console Kafka provides the utility kafka-console-producer.sh which is located at ~/kafka-training/kafka/bin/kafka-console-producer.sh to send messages to a topic on the command line.
In this section, the users will learn how a consumer consumes or reads the messages from the Kafka topics. There are following steps taken by the consumer to consume the messages from the topic: Step 1: Start the zookeeper as well as the kafka server initially.
I experienced the same problem and it seems like Kafka wrote wrong metadata to zookeeper.
The easiest way to get pass this is to remove the znode in which brokers data is being registered. I.e if you use the defaults, the name should be '/brokers' and the command:
$ zkCli.sh
...
[zk: localhost:2181(CONNECTED) 1] rmr /brokers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With