Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka broker is not available from localhost

I have installed kafka_2.11-1.1.0 and set advertised listener to advertised.listeners=PLAINTEXT://<my-ip>:9092 (in $KAFKA_HOME/config/server.properties).

I can connect and write to my kafka using java code and see my cluster via kafka-tool from another server but I can't write messages to my topic from my local machine (the one that I have installed kafka cluster on it).

I have also tried to set listeners value to listeners = PLAINTEXT://:9092 but there is no change. What should I do to my kafka to make it reachable and writable from both outside and inside of the localhost?

like image 853
Vahid F Avatar asked Dec 17 '18 10:12

Vahid F


3 Answers

In the server.properties use these two following properties

listeners=PLAINTEXT://0.0.0.0:9092 
advertised.listeners=PLAINTEXT://<your ip>:9092
like image 147
Bitswazsky Avatar answered Sep 24 '22 14:09

Bitswazsky


I finally solved the issue by changing my code's org.apache.kafka library from version 1.1.0 to version 2.1.0.

I mention that all of these libraries were imported (downloaded) and used via mvnrepository.com.

Also, our kafka producer and consumer code pattern were written using this article: https://dzone.com/articles/kafka-producer-and-consumer-example.

like image 31
Vahid F Avatar answered Sep 23 '22 14:09

Vahid F


Have a look in the below following links, it may be helpful for your scenario,

  • Kafka access inside and outside docker

  • Kafka Listeners - Explained

like image 22
Shiva Avatar answered Sep 20 '22 14:09

Shiva