Kafka SimpleConsumer无法连接到zookeeper:从频道读取时收到-1

时间:2015-05-29 00:57:17

标签: java sockets apache-zookeeper apache-kafka

我尝试通过SimpleConsumer连接到远程kafka zookeeper(.page),并为我已指定的主题提取元数据。但是,我收到了这个错误:

zookeeperhost:1234

我运行telnet zookeeperhost 1234并获得以下内容:

RunnerMain failed :java.io.EOFException: Received -1 when reading from channel, socket has likely been closed.

所以看起来我能够访问该服务,没有安全/许可问题。

这是我的代码:

Trying <ip addr of host>...
Connected to zookeeperhost.somedomain.com.
Escape character is '^]'.

1 个答案:

答案 0 :(得分:4)

您需要将SimpleConsumer连接到kafka领导者代理(默认情况下为端口9092)而不是zookeeper。查看此链接以获取有关如何使用SimpleConsumer的详细信息:https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example