Kafka.common.KafkaException: Wrong request type 18

use a simple java client to send a message after simulating the configuration of a kafka server, but without message storage, you can only see the error log all the time (the message is really not stored)

kafka.common.KafkaException: Wrong request type 18
    at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
    at kafka.network.Processor.read(SocketServer.scala:450)
    at kafka.network.Processor.run(SocketServer.scala:340)
    at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,032] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
    at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
    at kafka.network.Processor.read(SocketServer.scala:450)
    at kafka.network.Processor.run(SocketServer.scala:340)
    at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,087] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
    at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
    at kafka.network.Processor.read(SocketServer.scala:450)
    at kafka.network.Processor.run(SocketServer.scala:340)
    at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,140] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
    at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
    at kafka.network.Processor.read(SocketServer.scala:450)
    at kafka.network.Processor.run(SocketServer.scala:340)
    at java.lang.Thread.run(Thread.java:745)
[2018-03-24 11:12:14,244] ERROR Closing socket for /192.168.23.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 18
    at kafka.api.RequestKeys$.deserializerForKey(RequestKeys.scala:64)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:50)
    at kafka.network.Processor.read(SocketServer.scala:450)
    at kafka.network.Processor.run(SocketServer.scala:340)
    at java.lang.Thread.run(Thread.java:745)

after all, it is the java client that writes the dead loop output message, so there are not many redundant logs.
personally, I think there is something wrong with the size of the message set here by zookeeper or kafka, but I really don"t know where to change it. Ask for divine guidance

.

the following is the code for the simple java client
java
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.util.Properties;
public class ProducerTest {

public static void main(String[] args) {
    //todo:1
    Properties props = new Properties();
    props.put("bootstrap.servers","node1:9092");
    props.put("acks","all");
    props.put("retries",0);
    props.put("batch.size",16384);
    props.put("linger.ms",1);
    props.put("buffer.memory",33554432);
    props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
    props.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer");
    //todo:2kafkaProducer
    KafkaProducer<String,String> kafkaProducer = new KafkaProducer<String,String>(props);
    for (int i = 0; i <100; iPP){
        //todo:3kafka
        kafkaProducer.send(new ProducerRecord<String, String>
                ("test","sdfafasdgfak",
                        "Consumer Group(dfsadfa fasfasfasefawe4fawefawe fawef awfa)"));

    }
}

}


this problem is caused by the inconsistency between the version of kafka on your server and the version of kafka configured in your code. For example, if you deploy 2.1.10 on your server, the version number of kafka in maven in your local development environment is 0.8.10, but you use 2.1.12 when you develop, so this problem will occur

.
Menu