0

I'm trying to produce messages to a kafka container and it seems to fail on produce. connection seems OK.

docker-compose.yml
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
build: .
ports:
- "9092:9092"
- "9093:9093"
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_LISTENERS: INTERNAL://kafka:9093,EXTERNAL://127.0.0.1:9092
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9093,EXTERNAL://127.0.0.1:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock

tried with both :

.\kafka-console-producer.bat --broker-list 0.0.0.0:9092 --topic topicTest
and
.\kafka-console-producer.bat --broker-list localhost:9092 --topic topicTest

netstat shows listening on the port.

.\kafka-topics.bat --describe --zookeeper localhost:2181 --topic topicTest 
Topic:topicTest PartitionCount:1 ReplicationFactor:1 Configs:
Topic: topicTest Partition: 0 Leader: 1001 Replicas: 1001 Isr: 1001

any ideas ?

Builder Bob
  • 151
  • 1
  • 10
  • Does this answer your question? [Connect to Kafka running in Docker from local machine](https://stackoverflow.com/questions/51630260/connect-to-kafka-running-in-docker-from-local-machine) – OneCricketeer Dec 17 '19 at 01:28
  • 0.0.0.0:9092 isn't a real address. And the advertised listeners should take priority over advertised hostname – OneCricketeer Dec 17 '19 at 01:30
  • hi @cricket_007, the 0.0.0.0 was just for testing. also the advertised hostname. removing them doesn't work. – Builder Bob Dec 17 '19 at 06:11

1 Answers1

1

Found my issue!!!!

I've changed the following :

KAFKA_LISTENERS: INTERNAL://kafka:9093,EXTERNAL://127.0.0.1:9092
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9093,EXTERNAL://127.0.0.1:9092

into:

KAFKA_LISTENERS: INTERNAL://:9093,EXTERNAL://:9092
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9093,EXTERNAL://localhost:9092

and it worked.

I guess that the KAFKA_LISTENERS property should not have addressed the localhost or something.

Builder Bob
  • 151
  • 1
  • 10
  • listeners should just be `://0.0.0.0:`. Then you are telling the container to bind on all interfaces. The advertised listeners are how the clients actually communicate with that broker – OneCricketeer Dec 17 '19 at 07:17