Kafka SimpleConsumer无法连接到zookeeper:从频道读取时收到-1 [英] Kafka SimpleConsumer cannot connect to zookeeper : Received -1 when reading from channel

查看:76
本文介绍了Kafka SimpleConsumer无法连接到zookeeper:从频道读取时收到-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过SimpleConsumer连接到远程kafka zookeeper( zookeeperhost:1234 ),并提取我指定主题的元数据.但是,出现此错误:

I'm trying to connect to a remote kafka zookeeper (zookeeperhost:1234) via SimpleConsumer, and pulling metadata for the topics that I've specified. However, I get this error:

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

我运行telnet zookeeperhost 1234并得到以下信息:

I ran telnet zookeeperhost 1234 and got the following:

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

看来我可以使用该服务,没有安全/权限问题.

So it looks like I am able to reach the service, there is no security/permission issue.

这是我的代码:

SimpleConsumer consumer = new SimpleConsumer ("zookeeperhost", 1234, 100000, 64 * 1024, "leader_lookup");
List<String> topics = Collections.singletonList("some_event");
TopicMetadataRequest req = new TopicMetadataRequest(topics);
TopicMetadataResponse resp = consumer.send(req); //this is the line that is causing the error
List<TopicMetadata> metaData = resp.topicsMetadata();

推荐答案

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

You need to connect SimpleConsumer to a kafka leader broker (port 9092 by default) not a zookeeper. Check this link for the details how to use SimpleConsumer: https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example

这篇关于Kafka SimpleConsumer无法连接到zookeeper:从频道读取时收到-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆