apache-kafka

Configuring kafka listeners


I have this question regarding configuring kafka listeners properties correctly - listeners and advertised.listeners.

In my config I am setting below props:

listeners=SASL_PLAINTEXT://:9092

advertised.listeners=SASL_PLAINTEXT://u-kafkatst-kafkadev-5.sd.xxx.com:9092

The clients connect using u-kafkatst-kafkadev-5.sd.xxx.com:9092. Do I need to have the same value in listener and advertised.listeners. Here u-kafkatst-kafkadev-5.sd.xxx.com is a dns record that points to the host where kafka broker is running.

What are the situations where I would want to keep them same and different?

Thanks!


Solution

  • The advertised.listeners property is important if you are doing anything other than connecting to a broker directly on the same network. If you are using Docker, Kubernetes, IaaS (AWS, GCP, etc) then you need to expose the external address for the client to know where to connect to.