DevOps | Cloud | Analytics | Open Source | Programming





How To Fix - UnrecognizedBrokerVersion Error in Kafka Python ?



In this post , we will see How To Fix - UnrecognizedBrokerVersion Error in Kafka Python ? If you are using Kafka Python (may be as a Kafka Producer) , you might face the below issue -


\[ERROR\] UnrecognizedBrokerVersion: UnrecognizedBrokerVersion

raise Errors.UnrecognizedBrokerVersion()

I am assuming you are using -

  • KafkaProducer module from kafka-python package something like below -
 


from kafka import KafkaProducer
producer = KafkaProducer(<YOUR\_SETUP\_VARIABLES>)

Firstly understand that Kafka Producer has the below basic structure. We might not need all the details but good to know.


KafkaProducer(
               bootstrap\_servers=\['brokerhost1:port', 'brokerhost2:port', 'brokerhost3:port'\],
               ssl\_check\_hostname=True,
               ssl\_certfile=None,
               ssl\_keyfile=None,
               security\_protocol=<"SSL" or "SASL">
             )

So try the below piece of code , if that helps to fix the problem -


from kafka import KafkaProducer
from kafka import KafkaClient

producer = KafkaProducer(bootstrap\_servers=\['localhost:9092'\], ----> OR YOUR SPECIFIC HOST ADDRESS
                         security\_protocol="SSL")

  Hope this helps to solve the issue.   Other Reads -