0

I am very new to Docker and currently I am trying to connect to Kafka which is running inside docker container to a python client that is running separately in a different PC. The python client is running locally on a different PC and is not inside docker container.

When I try to produce and consume messages, I receive nothing on my client side, neither do I observe any error logs. The producer could not produce any messages on the topic and the consumer hence is not able to consume it.

Please find my docker compose file below:

version: '3.9'

services:

 zookeeper:
   image: wurstmeister/zookeeper
   container_name: zookeeper
   ports:
    - "2181:2181"

 kafka:
   image: wurstmeister/kafka
   container_name: kafka
   ports:
    - "9092:9092"
   depends_on:
     - zookeeper
   environment:
     KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
     KAFKA_ADVERTISED_HOST_NAME: "route -n | awk '/UG[ \t]/{print $$2}'"
     KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092

I have also tried changing the KAFKA_ADVERTISED_HOST_NAME to localhost but It also didn't help.

Kafka Logs:

[2023-01-10 15:04:08,711] INFO [SocketServer listenerType=ZK_BROKER, nodeId=1007] Starting socket server acceptors and processors (kafka.network.SocketServer)

[2023-01-10 15:04:08,766] INFO [SocketServer listenerType=ZK_BROKER, nodeId=1007] Started data-plane acceptor and processor(s) for endpoint : ListenerName(PLAINTEXT) (kafka.network.SocketServer)

[2023-01-10 15:04:08,767] INFO [SocketServer listenerType=ZK_BROKER, nodeId=1007] Started socket server acceptors and processors (kafka.network.SocketServer)

[2023-01-10 15:04:08,787] INFO Kafka version: 2.8.1 (org.apache.kafka.common.utils.AppInfoParser)

[2023-01-10 15:04:08,787] INFO Kafka commitId: 839b886f9b732b15 (org.apache.kafka.common.utils.AppInfoParser)

[2023-01-10 15:04:08,788] INFO Kafka startTimeMs: 1673363048767 (org.apache.kafka.common.utils.AppInfoParser)

[2023-01-10 15:04:08,801] INFO [KafkaServer id=1007] started (kafka.server.KafkaServer)

[2023-01-10 15:04:09,025] INFO [broker-1007-to-controller-send-thread]: Recorded new controller, from now on will use broker kafka:9092 (id: 1007 rack: null) (kafka.server.BrokerToControllerRequestThread)

I tried running changing the compose file of Kafka and tried to change KAFKA_ADVERTISED_LISTENERS value to my host machine running kafka but this also didn't help.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

0 Answers0