简体   繁体   English

kafka-python错误获取请求密钥

[英]kafka-python error getting request key

I am having trouble connecting to Cloudera Kafka version 2.0.1 (0.9.9.0) by using kafka-python versions both 1.2.4. 我无法同时使用kafka-python版本1.2.4和Cloudera Kafka版本2.0.1(0.9.9.0)。 and 1.2.5. 和1.2.5。 My python version is 2.6.6. 我的python版本是2.6.6。 Below is the command and exception stack trace: 下面是命令和异常堆栈跟踪:

>>> from kafka import KafkaProducer

>>> producer = KafkaProducer(bootstrap_servers='host')


2016-07-20 10:56:29,370 ERROR kafka.network.Processor: Closing socket for ###:9092 - ###:50257 because of error
kafka.network.InvalidRequestException: Error getting request for apiKey: 18 and apiVersion: 0
    at kafka.network.RequestChannel$Request.liftedTree2$1(RequestChannel.scala:93)
    at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:90)
    at kafka.network.Processor$$anonfun$run$11.apply(SocketServer.scala:426)
    at kafka.network.Processor$$anonfun$run$11.apply(SocketServer.scala:421)
    at scala.collection.Iterator$class.foreach(Iterator.scala:742)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at kafka.network.Processor.run(SocketServer.scala:421)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Unexpected ApiKeys id `18`, it should be between `0` and `16` (inclusive)
    at org.apache.kafka.common.protocol.ApiKeys.forId(ApiKeys.java:69)
    at org.apache.kafka.common.requests.AbstractRequest.getRequest(AbstractRequest.java:39)
    at kafka.network.RequestChannel$Request.liftedTree2$1(RequestChannel.scala:90)
    ... 9 more

I have verified I can connect by using kafka-console utilities on this machine, and also using the same versions of kafka-python on another machine. 我已经验证可以通过在这台机器上使用kafka-console实用程序进行连接,也可以在另一台机器上使用相同版本的kafka-python进行连接。 Has anyone seen this error or know what the problem may be? 有没有人看到此错误或知道可能是什么问题?

Thank you. 谢谢。

What makes you suspect a connection error in kafka-python? 是什么让您怀疑kafka-python中的连接错误? Was there some client error, or maybe other strange behavior? 是否存在一些客户端错误,或者其他奇怪的行为?

The error you pasted is from the broker, and simply reflects an attempt to identify the broker version by probing various newer api calls. 您粘贴的错误来自代理,仅反映通过尝试各种较新的api调用来识别代理版本的尝试。 You can safely ignore the error. 您可以放心地忽略该错误。 To prevent the version probe, pass an explicit api_version to your KafkaProducer. 为了防止版本探测,请将一个显式的api_version传递给您的KafkaProducer。 I assume api_version=(0, 9) is what you want here, but I'm not actually familiar with the vendored kafka distribution you have (Cloudera Kafka version 2.0.1). 我假设api_version=(0, 9)是您想要的,但是我实际上并不熟悉您所拥有的销售的kafka发行版(Cloudera Kafka版本2.0.1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM