I am using kafka-python for accessing Kafka. I try to create a Kafka Producer:
kafka_producer = KafkaProducer(bootstrap_servers=['kafka:9092'])
but this fails with exception kafka.errors.NoBrokersAvailable: NoBrokersAvailable.
I've found out I need to add api_version
parameter to the KafkaProducer:
kafka_producer = KafkaProducer(bootstrap_servers=['kafka:9092'],
api_version=(0, 10, 1))
This command works.
The question is: how to determine value of api_version
?
kafka-broker-api-versions.sh --bootstrap-server localhost:9092
gives me something, but I am not sure if there's a number I can use. I tried random values like api_version=(20, 2, 1)
and it also worked.
0.10.2
is a safe default – Strobileapi_version
parameter in KafkaProducer constructor, if it does not exist the class selects something on its own. – Cowpea