'Error in Zookeeper : Unreasonable length = 308375649 when creating topic in Kafka

I am setting up Kafka on my local Windows 10 machine. So downloaded all the required binaries and updated the two settings server and zookeeper properties as per the documentation.

But when running the Kafka create topic command

kafka-topics.bat --create --bootstrap-server 127.0.0.1:2181 --replication-factor 1 --partitions 1 --topic testtopic

I am getting below error in the Zookeeper window

WARN Close of session 0x0 (org.apache.zookeeper.server.NIOServerCnxn)
java.io.IOException: Unreasonable length = 308375649
        at org.apache.jute.BinaryInputArchive.checkLength(BinaryInputArchive.java:166)
        at org.apache.jute.BinaryInputArchive.readBuffer(BinaryInputArchive.java:127)
        at org.apache.zookeeper.proto.ConnectRequest.deserialize(ConnectRequest.java:91)
        at org.apache.zookeeper.server.ZooKeeperServer.processConnectRequest(ZooKeeperServer.java:1350)
        at org.apache.zookeeper.server.NIOServerCnxn.readConnectRequest(NIOServerCnxn.java:419)
        at org.apache.zookeeper.server.NIOServerCnxn.readPayload(NIOServerCnxn.java:180)
        at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:339)
        at org.apache.zookeeper.server.NIOServerCnxnFactory$IOWorkRequest.doWork(NIOServerCnxnFactory.java:522)
        at org.apache.zookeeper.server.WorkerService$ScheduledWorkRequest.run(WorkerService.java:154)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Can somebody help me here?



Solution 1:[1]

I faced similar issue, because I was trying to connect to the zookeeper instance (Port 2181) while providing the --bootstrap-server option. Later, I provided the Kafka broker details (localhost:9092) & it worked fine.

In the older Kafka version, we used to provide --zookeeper option & hence its instance.

Try this command -

bin/kafka-topics.sh --create --topic testtopic --bootstrap-server localhost:2181 --partitions 1 --replication-factor 1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dhanesh24g