当Kafka代理使用端口9093侦听SSL时,我的一段代码会抛出异常EOF,在纯文本侦听器中代码片段工作正常。
任何想法在这里可能出错?
public KafkaMetadataHelper(String kafkaConnect) throws Exception {
// use lowlevel kafka.api to query consumer group metadata (ie max committed offset)
String[] hostAndPort = kafkaConnect.split(":");
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
channel = new BlockingChannel(host, port,
BlockingChannel.UseDefaultBufferSize(),
BlockingChannel.UseDefaultBufferSize(),
10000);
channel.connect();
GroupCoordinatorRequest request = new GroupCoordinatorRequest(MY_GROUP,
GroupCoordinatorRequest.CurrentVersion(),
correlationId++,
MY_CLIENTID);
channel.send(request);
GroupCoordinatorResponse metadataResponse = null;
try {
metadataResponse = GroupCoordinatorResponse.readFrom(channel.receive().payload());// This is where the exception is thrown
} catch (Exception e) {
e.printStackTrace();
}
}
我得到的错误信息就是这个。
java.io.EOFException
at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:103)
at kafka.network.BlockingChannel.readCompletely(BlockingChannel.scala:131)
at kafka.network.BlockingChannel.receive(BlockingChannel.scala:122)
答案 0 :(得分:0)
要通过TLS连接,您的客户端需要一些设置! BlockingChannel
不允许来电者指定任何设置。
我建议您查看ConsumerGroupCommand.scala
[1],看看它如何使用AdminClient
[2]来检索有关消费者群体的详细信息。