I am trying to use Kafka.
All configurations are done properly but when I try to produce message from console I keep getting the following error
WARN Err
I have been witnessing this same issue in the last 2 weeks while working with Kafka and have been reading this Stackoverflow's post ever since.
After 2 weeks of analysis i have deduced that in my case this happens when trying to produce messages to a topic that doesn't exist.
The outcome in my case is that Kafka sends an error message back but creates, at the same time, the topic that did not exist before. So if I try to produce any message again to that topic after this event, the error will not appear anymore as the topic as been created.
PLEASE NOTE: It could be that my particular Kafka installation was configured to automatically create the topic when the same does not exist; that should explain why in my case I can see the issue only once for every topic after resetting the topics: your configuration might be different and in that case you would keep receiving the same error over and over.
Regards,
Luca Tampellini
Issue is resolved after adding the listener setting on server.properties file located at config directory. listeners=PLAINTEXT://localhost(or your server):9092 Restart kafka after this change. Version used 2.11
If you are running kafka on local machine, try updating $KAFKA_DIR/config/server.properties with below line:
listeners=PLAINTEXT://localhost:9092
and then restarting kafka.
I'm using kafka_2.12-0.10.2.1:
vi config/server.properties
add below line:
listeners=PLAINTEXT://localhost:9092
Hostname and port the broker will advertise to producers and consumers. If not set,
Otherwise, it will use the value returned from java.net.InetAddress.getCanonicalHostName()
.
stop the Kafka broker:
bin/kafka-server-stop.sh
restart broker:
bin/kafka-server-start.sh -daemon config/server.properties
and now you should not see any issues.
I am using docker-compose to build the Kafka container using wurstmeister/kafka
image. Adding KAFKA_ADVERTISED_PORT: 9092
property to my docker-compose
file solved this error for me.
For all those struggling with the Kafka ssl setup and seeing this LEADER_NOT_AVAILABLE error. One of the reasons that might be broken is the keystore and truststore. In the keystore you need to have private key of the server + signed server certificate. In the client truststore, you need to have intermedidate CA certificate so that client can authenticate the kafka server. If you will use ssl for interbroker communication, you need this truststore also set in the server.properties of the brokers so they can authenticate each other.
That last piece I was mistakenly missing and caused me a lot of painful hours finding out what this LEADER_NOT_AVAILABLE error might mean. Hopefully this can help somebody.