Kafka - Unable to send a message to a remote server using Java

后端 未结 4 1119
轻奢々
轻奢々 2020-12-09 09:46

I\'m trying to create a Kafka cluster to send messages to a remote control. I have configured everything as described here. I am running this on a Linux r

相关标签:
4条回答
  • 2020-12-09 10:05

    in config/server.properties
    I put this listeners=PLAINTEXT://[server_ip]:9092

    and it worked fine.

    For quick testing, don't forget to use [server_ip] in the command line of kafka-consumer. Example:

    /usr/local/kafka_2.11-2.0.0/kafka-console-consumer.sh --property print.timestamp=true --bootstrap-server [server_ip]:9092 --topic [you_topic]
    

    I hope this may help you.
    Regards Ali

    0 讨论(0)
  • 2020-12-09 10:05

    Tried connecting to kafka remote cluster from my local machine.

    VM's had one internal (9.0.0.1) and one external IP (192.1.1.1). I could ssh only to the internal & not the external. I did these changes to my conifg/server.properties:

    //set to the IP of the machine (find using ifconfig or hostname -I)

    listeners=PLAINTEXT://192.1.1.1:9092
    

    //set to the IP the consumer and producer will connect

    advertised.listeners=PLAINTEXT://9.0.0.1:9092  
    
    0 讨论(0)
  • 2020-12-09 10:13

    Worked with

    from server.properties Uncomment

    listeners=PLAINTEXT://:9092
    

    And

    advertised.listeners=PLAINTEXT://<HOST IP>:9092
    

    Replace <HOST IP> with actual IP.

    0 讨论(0)
  • 2020-12-09 10:22

    In your kafka server.properties there is a commented configuration

    #advertised.host.name=<Some IP>
    

    Uncomment this and add the IP of the Linux Machine in which kafka is running.

    advertised.host.name=<Kafka Running Machine IP>
    

    And connect from clients to <Kafka Running Machine IP> This should fix your issue.

    EDIT

    Optionally you can uncomment the

    #advertised.port=9092
    

    Also if you are listening on a different port than the default one.

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