Reputation: 71
I am new to kafka, I am just trying an example program in Hortonworks Sandbox. getting below error. Any help would be appreciated.
from kafka import KafkaProducer
from kafka.errors import KafkaError
producer = KafkaProducer(bootstrap_servers=['sandbox.hortonworks.com:9092'])
topic = "kafkatopic"
producer.send(topic, b'test message')
Traceback (most recent call last):
File "kaf_prod.py", line 4, in <module>
producer = KafkaProducer(bootstrap_servers=['sandbox.hortonworks.com:9092'])
File "/usr/lib/python2.6/site-packages/kafka/producer/kafka.py", line 334, in __init__
**self.config)
File "/usr/lib/python2.6/site-packages/kafka/client_async.py", line 204, in __init__
self.config['api_version'] = self.check_version(timeout=check_timeout)
File "/usr/lib/python2.6/site-packages/kafka/client_async.py", line 795, in check_version
raise Errors.NoBrokersAvailable()
kafka.errors.NoBrokersAvailable: NoBrokersAvailable
Upvotes: 1
Views: 273
Reputation: 1604
Kafka broker port is 6667 in hortonworks, not 9092. Try changing
producer = KafkaProducer(bootstrap_servers=['sandbox.hortonworks.com:9092'])
to
producer = KafkaProducer(bootstrap_servers=['sandbox.hortonworks.com:6667'])
Upvotes: 2
Reputation: 1411
Sounds like you cannot access the Kafka Brokers at sandbox.hortonworks.com:9092. I would suggest adding the ip of your sandbox VM to your host file so it can resolve sandbox.hortonworks.com
Upvotes: 0
Reputation: 1876
For exploring kafka , you can directly download apache kafka and run it in local.
Follow below links
Download https://kafka.apache.org/downloads
Quick start https://kafka.apache.org/quickstart
Upvotes: 0