Java connection zookeeper report KeeperErrorCode = AuthFailed

java connection zookeeper says KeeperErrorCode = AuthFailed

the environmental background of the problems and what methods you have tried

zookeeper has been started

related codes

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import kafka.consumer.Consumer;
import kafka.consumer.ConsumerConfig;
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import kafka.javaapi.consumer.ConsumerConnector;

/ *

  • @ author leicui bourne_cui@163.com

* /
public class Test extends Thread {

private final ConsumerConnector consumer;
private final String topic;

public Test(String topic)
{
    consumer = Consumer.createJavaConsumerConnector(
            createConsumerConfig());
    this.topic = topic;
}

private static ConsumerConfig createConsumerConfig()
{
    Properties props = new Properties();
    props.put("zookeeper.connect", "10.73.241.253:2181");
    props.put("group.id", "test-consumer-group");

/ / props.put ("zookeeper.session.timeout.ms", "40000");
/ / props.put ("zookeeper.sync.time.ms", "1000");
/ / props.put ("auto.commit.interval.ms", "1000");

    return new ConsumerConfig(props);
}

@Override
public void run() {
    Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
    topicCountMap.put(topic, new Integer(1));
    Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
    System.out.println("dssssssssssssss");
    KafkaStream<byte[], byte[]> stream = consumerMap.get(topic).get(0);
    ConsumerIterator<byte[], byte[]> it = stream.iterator();
    System.out.println("ddddd");
    while (it.hasNext()) {
        System.out.println("receive:" + new String(it.next().message()));
        try {
            sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

public static void main(String[] args) {
        new Test("test-topic").start();
}

}

what result do you expect? What is the error message actually seen?

Jun.30,2021
Menu