从信道读取时收到-1:卡夫卡SimpleConsumer不能连接到动物园管理员(Kafka Simp

2019-10-23 05:56发布

我试图连接到远程卡夫卡动物园管理员( zookeeperhost:1234通过SimpleConsumer),并拉动元数据,我已经指定的主题。 不过,我得到这个错误:

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

我跑的telnet zookeeperhost 1234,得到了以下几点:

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

因此,它看起来像我能到达的服务,没有安全/权限问题。

这里是我的代码:

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();

Answer 1:

您需要SimpleConsumer连接到卡夫卡领导代理(9092端口默认情况下)不是一个动物园管理员。 检查此链接的详细信息,如何使用SimpleConsumer: https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example



文章来源: Kafka SimpleConsumer cannot connect to zookeeper : Received -1 when reading from channel