kafka.common.KafkaException: Wrong request type 18

发布于 2022-09-07 03:47:30 字数 3627 浏览 12 评论 0

模拟配置kafka服务器后用简单的java客户端发送消息但是不见消息储存一直只能看到这个报错日志(消息确实没有储存)

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)

毕竟是java客户端写了死循环输出消息所以多余重复的日志就不多写了
小弟个人觉得是zookeeper这里或是kafka这里设置的消息大小有问题,但是确实不知道改哪里,求大神指导

下面是简易java客户端的代码
···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:2、创建kafkaProducer
    KafkaProducer<String,String> kafkaProducer = new KafkaProducer<String,String>(props);
    for (int i = 0; i <100; i++){
        //todo:3、发送数据给kafka
        kafkaProducer.send(new ProducerRecord<String, String>
                ("test","sdfafasdgfak",
                        "Consumer Group(dfsadfa fasfasfasefawe4fawefawe fawef awfa)"));

    }
}

}
···

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凶凌 2022-09-14 03:47:30

这个问题是由于你服务器上的kafka版本和你代码中配置的kafka版本不一致导致的,比如你服务器上部署的是2.1.10 这个对应你本地开发环境中maven中kafka的版本号是0.8.10 但是你开发的时候用的却是2.1.12 这样就会出现这个问题

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文