question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on starting up Kafka

See original GitHub issue

Hi I am getting these errors in the console when running a test with a very simple example:

10:47:40.333 [kafka-network-thread-1-ListenerName(PLAINTEXT)-PLAINTEXT-0] DEBUG org.apache.kafka.common.network.Selector - [SocketServer brokerId=1] Connection with /127.0.0.1 disconnected
java.io.EOFException: null
	at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:96)
	at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:381)
	at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:342)
	at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:609)
	at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:541)
	at org.apache.kafka.common.network.Selector.poll(Selector.java:467)
	at kafka.network.Processor.poll(SocketServer.scala:689)
	at kafka.network.Processor.run(SocketServer.scala:594)
	at java.lang.Thread.run(Thread.java:748)
10:47:40.333 [kafka-network-thread-1-ListenerName(PLAINTEXT)-PLAINTEXT-1] DEBUG org.apache.kafka.common.network.Selector - [SocketServer brokerId=1] Connection with /127.0.0.1 disconnected
java.io.EOFException: null
	at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:96)
	at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:381)
	at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:342)
	at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:609)
	at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:541)
	at org.apache.kafka.common.network.Selector.poll(Selector.java:467)
	at kafka.network.Processor.poll(SocketServer.scala:689)
	at kafka.network.Processor.run(SocketServer.scala:594)
	at java.lang.Thread.run(Thread.java:748)

I am using the following versions:

  • <kafka.version>2.1.1</kafka.version>
  • <kafka.junit4.version>3.1.0</kafka.junit4.version>

And this is the code:

    @ClassRule
    public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource();

    @Test
    public void kafkaTest() {

        long timeout = 1000L * 60L * 5L;
        long start = System.currentTimeMillis();

        while (System.currentTimeMillis() - start <= timeout) {

        }

        System.out.println("Exiting test");
    }

However, I tested Kafka directly from the console (kafka-console-consumer.sh and kafka-console-producer.sh) and it seems to be working properly.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
MatanRubincommented, Jul 7, 2019

@Crim, feel free to ignore my last comment. I saw many exceptions in the test log and thought it meant the server is not ready, but then I re-read this thread and understood that these exceptions are shown in DEBUG level and are not an actual issue.

I created a small test just to make sure everything is working properly - and it does. Posting the test here for posterity.

public class KafkaTest {

    @ClassRule
    public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource();

    @Test
    public void testSendReceive() throws TimeoutException {
        KafkaTestUtils testUtils = sharedKafkaTestResource.getKafkaTestUtils();

        // wait for broker to start listening
        testUtils.waitForBrokerToComeOnLine(1, 10, TimeUnit.SECONDS);

        String topicName = "testTopic";
        testUtils.createTopic(topicName, 1, (short) 1);

        KafkaProducer<String, String> producer =
                testUtils.getKafkaProducer(StringSerializer.class, StringSerializer.class);
        producer.send(new ProducerRecord<>(topicName, null, "value"));

        Properties properties = new Properties();
        properties.put(ConsumerConfig.GROUP_ID_CONFIG, "group-id");
        KafkaConsumer<String, String> consumer =
                testUtils.getKafkaConsumer(StringDeserializer.class, StringDeserializer.class, properties);
        consumer.subscribe(Collections.singletonList(topicName));
        ConsumerRecords<String, String> records = consumer.poll(Duration.ofSeconds(10));
        for (ConsumerRecord<String, String> record : records) {
            Assert.assertEquals("value", record.value());
        }
    }
}
0reactions
MatanRubincommented, Jul 8, 2019

cool, thanks for letting me know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

apache zookeeper - error while starting kafka broker
If the Kafka broker is brought up before this happens, the broker shuts down with "Error while creating ephemeral at /broker/ids/id, node already...
Read more >
error during KafkaServerStartable startup Prepare ... - Edureka
This error occurs because zookeeper is running already. So kill the process first and then try again and it will work. $ ps...
Read more >
Startup ERROR in 8.4 Failed to start Kafka on 1 attempt, kafka ...
While starting Pega personal edition 8.4 getting file not found exception (while starting Kafka) can anyone halp me to solve this?
Read more >
Unable to start kafka with zookeeper (kafka.common ...
Open server server.properties file which is located in your kafka folder kafka_2.11-2.4.0\config (considering your version of kafka, folder name ...
Read more >
Kafka Streams - Error while starting up - Google Groups
It means it can't find any available kafka brokers. You should ensure that bootstrap.servers is set correctly, i.e., the brokers are valid. Also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found