ERROR Error when sending message to topic

前端 未结 13 2080
借酒劲吻你
借酒劲吻你 2020-12-28 13:46

While producing message in kafka, i am getting the following error :

$ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic nil_PF1_P1
hi
hello         


        
相关标签:
13条回答
  • 2020-12-28 14:17

    I faced the above exception stacktrace. I investigated and found the root cause.I faced it when I established Kafka cluster with two nodes.With the following settings in server.properties.Here I am denoting server.properties of kafka node 1 and 2 as broker1.properties and broker2.properties

    broker1.properties settings

        listeners=PLAINTEXT://A.B.C.D:9092
        zookeeper.connect=A.B.C.D:2181,E.F.G.H:2181
    

    broker2.properties settings

        listeners=PLAINTEXT://E.F.G.H:9092
        zookeeper.connect=A.B.C.D:2181,E.F.G.H:2181
    

    I was trying to start a producer from node1 or from node2 using the following command: ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic OUR_TOPIC and I was getting the above timeout exception stacktrace although Kafka is running in both machine.

    Although producer is starting either from Leader node or from a follower I was always getting the same.

    While using below command from any broker I was able to get producer the message.

       ./bin/kafka-console-producer.sh --broker-list A.B.C.D:9092 --topic OUR_TOPIC
        or
       ./bin/kafka-console-producer.sh --broker-list E.F.G.H:9092 --topic OUR_TOPIC
       or
       ./bin/kafka-console-producer.sh --broker-list A.B.C.D:9092,E.F.G.H:9092 --topic OUR_TOPIC
    

    So the root cause is that Kafka broker internally using listeners=PLAINTEXT://E.F.G.H:9092 property while staring a producer.This property must match to start a kafka broker from any of the node while starting a producer.Converting this property to listeners=PLAINTEXT://localhost:9092 will work for our very first command.

    0 讨论(0)
提交回复
热议问题