I’m trying to make a connection to Kafka on AWS. Communication is done over TLS.<br> Kafka-python==2.0.2 is used, and the KafkaProducer configuration is as follows:
From Kafka import KafkaProducer
producer = KafkaProducer(
bootstrap_servers=boostrap_servers, # I have three brokers in my Kafka cluster.
security_protocol='SSL',
ssl_check_hostname=False,
ssl_cafile=ssl_cafile,
value_serializer=lambda x: json.dumps(x, ensure_ascii=False).encode("utf-8"),
)
I run into NoBrokersAvailble Error intermittently without a pattern. The connection continues to fail for a moment once NoBrokersAvailable occurs.
I already checked if there's any problem connecting with the Kafka cluster on AWS:
So these are my questions:
In my case, I specified the kafka version while creating the Producer instance and I don't see the NoBrokersAvailable Errors anymore.
producer = KafkaProducer(bootstrap_servers='localhost:9092',
value_serializer=lambda v: json.dumps(v).encode('utf-8'),
max_request_size=20971520,api_version = (2, 8, 0))
You can get the kafka version by running kafka-topic.sh:
kafka/bin/kafka-topics.sh --version
Output:
2.8.0 (Commit:ebb1d6e21cc92130)