0

I a consuming Kafka messages from Kafka cli with following command kafka-console-consumer.bat --bootstrap-server kafka:9092 --from-beginning --topic mytopic --consumer.config ....\config\consumer.properties

and I am getting following errors

[2022-09-23 15:59:33,175] WARN [Consumer clientId=console-consumer, groupId=group] Bootstrap broker kafka:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2022-09-23 15:59:54,344] WARN [Consumer clientId=console-consumer, groupId=group] Connection to node -1 (kafka:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2022-09-23 15:59:54,345] WARN [Consumer clientId=console-consumer, groupId=group] Bootstrap broker kafka:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2022-09-23 16:00:15,634] WARN [Consumer clientId=console-consumer, groupId=group] Connection to node -1 (kafka:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

I have updated server.properties with following configuration

port = 9092
advertised.host.name = kafka
KAFKA_CFG_LISTENERS=PLAINTEXT://kafka:9092
advertised.listeners=PLAINTEXT://kafka:9092
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • `KAFKA_CFG_LISTENERS` is a property of bitnami docker container, not Kafka itself... Where are you actually running Kafka? In a container, or not? Also, port and advertised.host.name are deprecated properties, and should be removed – OneCricketeer Sep 23 '22 at 14:32
  • If you are using bitnami Kafka container, please read https://stackoverflow.com/questions/51630260/connect-to-kafka-running-in-docker#51634499 – OneCricketeer Sep 23 '22 at 14:34

1 Answers1

0

Hey the main issue is that it cannot connect to your specified bootstrap server.

Hey can you ping kafka:9092 when you on that machine? If no than you have to ensure to make kafka:9092 available in your network.

Troubleshooting steps:

  1. Check if the machine can resolve kafka to an IP or try to call the direct IP instad of the service name "kafka"
  2. Did you specify an IP mapping in the hostfile

cat /etc/hosts | grep kafka

should give you the local ip mapping if not you can add the Ip mapping here. you have to use "sudo vim /etc/hosts" since this file is readonly

  1. If you are on Docker ensure that you are running on the same network "--net".
  2. If you are on Kubernetes ensure that your service that is exposing kafka is called kafka.

If this all not help please comment and we can look furher.

pwoltschk
  • 550
  • 1
  • 3
  • 22