How to connect zookeeper using sarama go client?

306 Views Asked by At

I am a beginner at using the sarama client. Although my code is working fine with the bootstrap servers but unable to connect with the zookeepers.

kafka node version: confluent-kafka-2.11-0.10.2.1-2.noarch
sarama client version: v1.38.0

config := kafka.NewConfig()
broker := []string{"localhost:9092"}
kafkaClient, err := kafka.NewClusterAdmin(broker, config)

Error:
kafka: client has run out of available brokers to talk to: EOF

1

There are 1 best solutions below

0
On

Your error simply says Kafka isn't running at the host:port you've provided, and has nothing to do with Zookeeper


Sarama is a Kafka client. You should not be using it to connect to Zookeeper.

If you need to execute Zookeeper operations, you will need a different library, but you should never need Zookepeer operations for a Kafka application. KafkaAdminClient will forward any requests to Zookeeper, if it needs to (unless you run Kafka in Kraft mode, where Zookeeper isn't used).