I am trying to connect to Kafka with Kafka-Python, the Kafka cluster has Kerberos, we need to collect some commands in order to take a few steps.
I created one topic in the cluster and I ran a test with ./kafka-console-producer.sh and ./kafka-console-consumer.sh and it works very well.
But when I try to connect to Kafka-Python, I have a problem. See my code below:
def produce(): print ('Producer') k_producer = KafkaProducer(bootstrap_servers='hostname:6667', security_protocol='SASL_PLAINTEXT', sasl_plain_username='machine_usr', sasl_plain_password='machine_pwd', sasl_mechanism='PLAIN') for i in range(10): print ('Before send') k_producer.send('myTopic', 'Testing My Topic ' + str(i)) print ('After send')
Well, by running this stuff, I got this erro message after 30 seconds:
File "C:\Users\m\kafka-python-1.3.1\kafka.zip\kafka\producer\kafka.py", line 328, in __init__ File "C:\Users\m\kafka-python-1.3.1\kafka.zip\kafka\client_async.py", line 202, in __init__ File "C:\Users\m\kafka-python-1.3.1\kafka.zip\kafka\client_async.py", line 791, in check_version kafka.errors.NoBrokersAvailable: NoBrokersAvailable
I run it on a remote machine. And bootstrap_server I used the name and port of Zookeeper, but it didn’t work.
I found a few things about this, and in git Kafka-Python I found that they are implemented .
Is there any other way to connect?
python apache-kafka
Thiago baldim
source share