kafka-python: producer is not able to connect

后端 未结 7 2053
你的背包
你的背包 2020-12-16 00:29

kafka-python (1.0.0) throws error while connecting to the broker. At the same time /usr/bin/kafka-console-producer and /usr/bin/kafka-console-consumer work fine.

Pyt

相关标签:
7条回答
  • 2020-12-16 01:27

    I had the same problem, and none of the solutions above worked. Then I read the exception messages and it seems it's mandatory to specify api_version, so

    producer = KafkaProducer(bootstrap_servers=['localhost:9092'],api_version=(0,1,0))
    

    note: tuple (1,0,0) matching to kafka version 1.0.0

    works fine (at least completes without exceptions, now have to convince it to accept messages ;) )

    0 讨论(0)
提交回复
热议问题