Ramesh Ganesan
Ramesh Ganesan

Reputation: 71

Apache kafka error in Hortonworks

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')

Error:

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

Answers (3)

matesio
matesio

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

Aaron
Aaron

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

Liju John
Liju John

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

Related Questions