Java客户端连接kafka集群报错
Posted 静候东风
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java客户端连接kafka集群报错相关的知识,希望对你有一定的参考价值。
往kafka集群发送消息时,报错如下:
page_visits-1: 30005 ms has passed since batch creation plus linger time
加入log4j.properties,设置为DEBUG级别,错误如下:
2017-06-03 17:33:31,417 DEBUG [org.apache.kafka.clients.NetworkClient] - Error connecting to node 2 at kafka-cluster-64bit:9094:
java.io.IOException: Can‘t resolve address: kafka-cluster-64bit:9094
at org.apache.kafka.common.network.Selector.connect(Selector.java:182)
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:629)
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:186)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:184)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:126)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:101)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622)
at org.apache.kafka.common.network.Selector.connect(Selector.java:179)
... 5 more
解决办法:
config/server.properties修改
修改前:listeners=PLAINTEXT://:9092
修改后:listeners=PLAINTEXT://192.168.137.176:9092
具体代码参照:Kafka JAVA客户端代码示例
以上是关于Java客户端连接kafka集群报错的主要内容,如果未能解决你的问题,请参考以下文章
带有 Kafka 的 Docker 集群无法与客户端容器建立连接
java客户端作为kafka的consumer报错org.I0Itec.zkclient.exception.ZkTimeoutException
java客户端作为kafka的consumer报错org.I0Itec.zkclient.exception.ZkTimeoutException