Help: NoBrokersAvailable
See original GitHub issuehi in kafka_2.11-0.10.1.0 version use kafka-python to connect error
use bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning is correct
my python code:
from kafka import KafkaConsumer
consumer = KafkaConsumer('test',bootstrap_servers=['localhost:9092'])
for message in consumer:
print ("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition, message.offset, message.key, message.value))
error message:
Traceback (most recent call last):
File “pkafka.py”, line 5, in <module>
bootstrap_servers=[‘localhost:9092’])
File “/usr/lib/python2.7/site-packages/kafka_python-1.3.2.dev0-py2.7.egg/kafka/consumer/group.py”, line 287, in init
self._client = KafkaClient(metrics=self._metrics, **self.config)
File “/usr/lib/python2.7/site-packages/kafka_python-1.3.2.dev0-py2.7.egg/kafka/client_async.py”, line 204, in init
self.config[‘api_version’] = self.check_version(timeout=check_timeout)
File “/usr/lib/python2.7/site-packages/kafka_python-1.3.2.dev0-py2.7.egg/kafka/client_async.py”, line 813, in check_version
raise Errors.NoBrokersAvailable()
kafka.errors.NoBrokersAvailable: NoBrokersAvailable
Issue Analytics
- State:
- Created 7 years ago
- Comments:26 (4 by maintainers)
In case someone faces the exact same issue as I did, I believe my kafka config was the issue. I’ve added an explicit listener line to my config
config/server.properties
and it resolved the issue.Hi all – NoBrokersAvailable is raised in this scenario if bootstrapping metadata failed. Bootstrapping relies exclusively on
bootstrap_servers
. If you are seeing this error it is because kafka-python was unable to connect to any of the brokers you configured as bootstrap_servers.If you want to find out more about what is happening under the covers, enable debug logging:
In addition there will be some additional connection logging in the next release and that should make it even easier to diagnose networking problems like this.