kafka-python (1.0.0) throws an error when connecting to a broker. At the same time, / usr / bin / kafka-console-producer and / usr / bin / kafka-console-consumer are working fine.
The Python application also works well, but after restarting the zookeeper it can no longer connect.
I use the bare bones example from the docs:
from kafka import KafkaProducer from kafka.common import KafkaError producer = KafkaProducer(bootstrap_servers=['hostname:9092'])
I get this error:
Traceback (most recent call last): File "pp.py", line 4, in <module> producer = KafkaProducer(bootstrap_servers=['hostname:9092']) File "/usr/lib/python2.6/site-packages/kafka/producer/kafka.py", line 246, in __init__ self.config['api_version'] = client.check_version() File "/usr/lib/python2.6/site-packages/kafka/client_async.py", line 629, in check_version connect(node_id) File "/usr/lib/python2.6/site-packages/kafka/client_async.py", line 592, in connect raise Errors.NodeNotReadyError(node_id) kafka.common.NodeNotReadyError: 0 Exception AttributeError: "'KafkaProducer' object has no attribute '_closed'" in <bound method KafkaProducer.__del__ of <kafka.producer.kafka.KafkaProducer object at 0x7f6171294c50>> ignored
When navigating through (/usr/lib/python2.6/site-packages/kafka/client_async.py), I noticed that line 270 evaluates to false:
270 if not self._metadata_refresh_in_progress and not self.cluster.ttl() == 0: 271 if self._can_send_request(node_id): 272 return True 273 return False
In my case, self._metadata_refresh_in_progress is False, but ttl () = 0;
At the same time, kafka-console- * joyfully pushes messages around:
/usr/bin/kafka-console-producer --broker-list hostname:9092 --topic test-topic hello again hello2
Any tips?
apache-kafka kafka-python
alex_123
source share