0

I have a Kafka docker set up that I was able to run properly with the following docker-compose.yml.

> version: '2'
> 
> services:
>     zookeeper:
>         image: bitnami/zookeeper:3.8
>         ports:
>             - 2181:2181
>         environment:
>             - ALLOW_ANONYMOUS_LOGIN=yes
>             #- ZOO_ENABLE_AUTH=yes
>     kafka:
>         image: bitnami/kafka:2.5.0
>         ports:
>             - 9092:9092
>             - 9091:9091
>         links:
>             - zookeeper
>         environment:
>             - ALLOW_PLAINTEXT_LISTENER=true
>             - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
>             - KAFKA_LISTENERS=INTERNAL://kafka:9091,EXTERNAL://localhost:9092
>             - KAFKA_ADVERTISED_LISTENERS=EXTERNAL://localhost:9092,INTERNAL://kafka:9091
>             - KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL
>             - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT

I am trying to connect using conflient-kafka and my producer code looks as below

from confluent_kafka import Producer
import socket

conf = {'bootstrap.servers': "127.0.0.1:9092",
        "enable.ssl.certificate.verification": False,
        'client.id': socket.gethostname()}

producer = Producer(conf)
producer.produce('my_topic', key="key", value="value")
producer.flush()

I am having the following error when I run it

Disconnected while requesting ApiVersion: might be caused by incorrect security.protocol configuration (connecting to a SSL listener?) or broker version is < 0.10 (see api.version.request) (after 2ms in state APIVERSION_QUERY)

I noticed the following

  • Kafka broker version is 2.5.
  • docker-compose log shows ssl.client.auth = none ssl.enabled.protocols = [TLSv1.2]

Can anyone suggest how to resolve this issue?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
kta
  • 19,412
  • 7
  • 65
  • 47
  • Putting localhost in `KAFKA_LISTENERS` stops remote connections from being made. Use `EXTERNAL://:9092` or put 0.0.0.0, not localhost. Only put localhost in the advertised listeners. You might also want to use a newer version of the container (versions 3.4+ don't need Zookeeper). You can also remove the forwarded 9091 port since that's not doing anything – OneCricketeer Sep 03 '23 at 00:23

0 Answers0