pepper-box
pepper-box copied to clipboard
Kafka Consumer throws NullPointerExcception (ERROR o.a.z.ClientCnxn: Error while calling watcher )
The version used: JMeter Version: 5.0 Kafka version: 2.0
Consumer Configurations:
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.serialization.StringDeserializer;
import java.util.Arrays;
import java.util.Properties;
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "techforum-group-perftest");
props.put("enable.auto.commit", "true");
props.put("auto.commit.interval.ms", "1000");
props.put("session.timeout.ms", "30000");
props.put("key.deserializer",
"org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer",
"org.apache.kafka.common.serialization.StringDeserializer");
KafkaConsumer<String, String> consumer = new KafkaConsumer<String, String>(props);
consumer.subscribe(Arrays.asList("temp-topic"));
System.out.println("Subscribed to topic temp-topic");
int i = 0;
while (true) {
ConsumerRecords<String, String> records = consumer.poll(100);
for (ConsumerRecord<String, String> record : records)
System.out.printf("offset = %d, key = %s, value = %s\n",
record.offset(), record.key(), record.value());
}
Getting following error while listenening to the messages.
2018-11-11 17:46:18,875 INFO o.a.z.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
2018-11-11 17:46:18,915 INFO o.a.z.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x16704e8ff960003, negotiated timeout = 10000
2018-11-11 17:46:18,919 ERROR o.a.z.ClientCnxn: Error while calling watcher
java.lang.NullPointerException: null
at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:533) [pepper-box-1.0.jar:?]
at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:508) [pepper-box-1.0.jar:?]```
I tried to build the pepper-box jat but the test PepperBoxConfigElementTest.java fails with same error.
If I remove the list of zookeeper instances from the "zookeeper.servers" (but I still have my "bootstrap.servers" to Kafka) then the error goes away and the test completes (sends the request to the topic) successfully.
However, it would be nice to understand why the error is happening and if there is a resolution.
I'm also getting this same error, any updates?
Yep, I have the same problem
i have same problem too
Per https://stackoverflow.com/questions/24049296/error-org-apache-zookeeper-clientcnxn-error-while-calling-watcher I just added: import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; . .. class StubWatcher implements Watcher { public void process(WatchedEvent event) { // just to keep new ZooKeeper happy later. } }
and changed: ZooKeeper zk = new ZooKeeper(zookeeperServers, 10000, new PepperBoxLoadGenerator.StubWatcher());