无法从Python代码生成Kafka

时间:2017-10-16 16:18:21

标签: python apache-kafka apache-zookeeper kafka-producer-api

我运行了这些模块(全部是本地的):

  • 动物园管理员
  • Kafka Server
  • Kafka Consumer
  • Python脚本

在脚本中有一个send()电话:

producer = KafkaProducer(bootstrap_servers=['localhost:9092'])
producer.send('test', 'entry1')
每隔15秒左右。 几乎每个send()调用都会在The Kafka Server上产生这些错误:

[2017-10-16 18:59:10,953] ERROR Closing socket for /127.0.0.1 because of error (kafka.network.Processor)
kafka.common.KafkaException: Wrong request type 16
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:748)
[2017-10-16 18:59:11,158] INFO Closing socket connection to /127.0.0.1. (kafka.network.Processor)
[2017-10-16 18:59:11,162] INFO Closing socket connection to /127.0.0.1. (kafka.network.Processor)
[2017-10-16 18:59:11,162] ERROR Closing socket for /127.0.0.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:748)

这是一个差不多,因为每5分钟(或多或少)该条目确实可以获得消费者权利,但随后错误将重现。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

看起来Kafka版本与Python客户端版本不兼容 - 请检查它们。可以找到操作代码列表here