我正在尝试使用Spring Kafka客户端连接到Kafka服务器&我在日志中看到以下错误。我正在连接到我验证的特定kafka代理IP。我似乎在下面的错误日志中看到本地引用。你能帮我调试一下吗?
我正在使用logback.xml。以下是配置。我在测试之前硬编码了kafka主机和端口。相同的代码和配置适用于其中一种环境。
<appender name="asyncVerboseKafka"
class="net.logstash.logback.appender.LoggingEventAsyncDisruptorAppender">
<appender name="kafkaVerboseAppender"
class="com.github.danielwegener.logback.kafka.KafkaAppender">
<encoder
class="com.github.danielwegener.logback.kafka.encoding.LayoutKafkaMessageEncoder">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>verbose-${springActiveProfile}- %msg</pattern>
</layout>
</encoder>
<topic>${verbosetopic}</topic>
<keyingStrategy
class="com.github.danielwegener.logback.kafka.keying.RoundRobinKeyingStrategy" />
<deliveryStrategy
class="com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy" />
<producerConfig>bootstrap.servers=${kafkaHostName}:${kafkaHostPort}
</producerConfig>
<producerConfig>retries=2</producerConfig>
</appender>
</appender>
2017-10-18T15:33:50.650-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.649 DEBUG - org.apache.kafka.clients.NetworkClient :节点-1已断开连接。 2017-10-18T15:33:50.650-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.649调试 - org.apache.kafka.clients.NetworkClient:放弃发送元数据 请求,因为没有节点可用2017-10-18T15:33:50.650-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.649调试 - o.apache.kafka.common.network.Selector:与...连接 localhost / 127.0.0.1已断开连接2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.749调试 - org.apache.kafka.clients.NetworkClient:初始化与节点的连接 -1发送元数据请求2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33: 50.750 DEBUG - org.apache.kafka.clients.NetworkClient:启动与节点的连接 -1在localhost:9092。 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.750调试 - org.apache.kafka.clients.NetworkClient:初始化与节点的连接 -1发送元数据请求2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33: 50.750 DEBUG - o.apache.kafka.common.network.Selector:与...连接 localhost / 127.0.0.1已断开连接2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at sun.nio.ch.SocketChannelImpl.checkConnect(本机方法) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] java.net.ConnectException:连接被拒绝 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:54) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:270) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:79) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.Selector.poll(Selector.java:274) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at java.lang.Thread.run(Thread.java:745)2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:216) 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.750 DEBUG - org.apache.kafka.clients.NetworkClient :节点-1已断开连接。 2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.750 DEBUG - org.apache.kafka.clients.NetworkClient:放弃发送元数据 请求,因为没有节点可用2017-10-18T15:33:50.750-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:128) 2017-10-18T15:33:50.751-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.750 DEBUG - org.apache.kafka.clients.NetworkClient :放弃发送元数据请求,因为没有节点可用 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:79) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:128) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at java.lang.Thread.run(Thread.java:745)2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.851调试 - o.apache.kafka.common.network.Selector:与...连接 localhost / 127.0.0.1已断开连接2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.Selector.poll(Selector.java:274) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.850 DEBUG - org.apache.kafka.clients.NetworkClient :在localhost:9092处启动与节点-1的连接。 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:216) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.851 DEBUG - org.apache.kafka.clients.NetworkClient :节点-1已断开连接。 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.851调试 - org.apache.kafka.clients.NetworkClient:放弃发送元数据 请求,因为没有节点可用2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.850调试 - org.apache.kafka.clients.NetworkClient:初始化与节点的连接 -1发送元数据请求2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:270) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:54) 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] java.net.ConnectException:连接被拒绝 2017-10-18T15:33:50.851-04:00 [APP / PROC / WEB / 0] [OUT] at sun.nio.ch.SocketChannelImpl.checkConnect(本机方法) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.952 DEBUG - o.apache.kafka.common.network.Selector :与localhost / 127.0.0.1断开连接 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:79) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:216) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:128) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at java.lang.Thread.run(Thread.java:745)2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at sun.nio.ch.SocketChannelImpl.checkConnect(本机方法) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:54) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:270) 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.951 DEBUG - org.apache.kafka.clients.NetworkClient :在localhost:9092处启动与节点-1的连接。 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] java.net.ConnectException:拒绝连接
答案 0 :(得分:1)
在localhost:9092处启动与节点-1的连接。 2017-10-18T15:33:50.952-04:00 [APP / PROC / WEB / 0] [OUT] java.net.ConnectException:拒绝连接
表示主机/端口不正确;它尝试在本地计算机上连接到Kafka。
您需要显示如何在属性中配置引导服务器。