Punter Vicky
Punter Vicky

Reputation: 17042

Issue connecting to Kafka Broker

I am trying to connect to Kafka server using Spring Kafka client & I see the below error in the logs. I am connecting to an specific kafka broker IP which I verified.I seem to see local references in the below error log. Could you please help me debug this further?

I am pushing using logback.xml. Below is the configuration. I hardcoded the kafka host and port before testing. The same code and configuration works in one of the environments.

<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 : Node -1 disconnected. 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 : Give up sending metadata request since no node is available 2017-10-18T15:33:50.650-04:00 [APP/PROC/WEB/0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.649 DEBUG - o.apache.kafka.common.network.Selector : Connection with localhost/127.0.0.1 disconnected 2017-10-18T15:33:50.750-04:00 [APP/PROC/WEB/0] [OUT] [] [] [] [] [] 2017-10-18 15:33:50.749 DEBUG - org.apache.kafka.clients.NetworkClient : Initialize connection to node -1 for sending metadata request 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 : Initiating connection to node -1 at localhost:9092. 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 : Initialize connection to node -1 for sending metadata request 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 : Connection with localhost/127.0.0.1 disconnected 2017-10-18T15:33:50.750-04:00 [APP/PROC/WEB/0] [OUT] at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 2017-10-18T15:33:50.750-04:00 [APP/PROC/WEB/0] [OUT] java.net.ConnectException: Connection refused 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 : Node -1 disconnected. 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 : Give up sending metadata request since no node is available 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 : Give up sending metadata request since no node is available 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 DEBUG - o.apache.kafka.common.network.Selector : Connection with localhost/127.0.0.1 disconnected 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 : Initiating connection to node -1 at localhost:9092. 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 : Node -1 disconnected. 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 : Give up sending metadata request since no node is available 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 : Initialize connection to node -1 for sending metadata request 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: Connection refused 2017-10-18T15:33:50.851-04:00 [APP/PROC/WEB/0] [OUT] at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 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 : Connection with localhost/127.0.0.1 disconnected 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(Native Method) 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 : Initiating connection to node -1 at localhost:9092. 2017-10-18T15:33:50.952-04:00 [APP/PROC/WEB/0] [OUT] java.net.ConnectException: Connection refused

Upvotes: 4

Views: 9946

Answers (1)

Gary Russell
Gary Russell

Reputation: 174799

Initiating connection to node -1 at localhost:9092. 2017-10-18T15:33:50.952-04:00 [APP/PROC/WEB/0] [OUT] java.net.ConnectException: Connection refused

Means the host/port is incorrect; it's trying to connect to Kafka on your local machine.

You need to show how you configured the bootstrap servers in the properties.

Upvotes: 1

Related Questions