Why I cannot connect to Kafka from outside?

前端 未结 8 1993
梦毁少年i
梦毁少年i 2020-12-02 14:19

I am running kafka on ec2 instance. So amazon ec2 instance has two ips one is internal ip and second one is for external use.

I created producer from local machine,

8条回答
  •  遥遥无期
    2020-12-02 15:06

    In the Kafka FAQ (updated for new properties) you can read:

    When a broker starts up, it registers its ip/port in ZK. You need to make sure the registered ip is consistent with what's listed in bootstrap.servers in the producer config. By default, the registered ip is given by InetAddress.getLocalHost.getHostAddress(). Typically, this should return the real ip of the host. However, sometimes (e.g., in EC2), the returned ip is an internal one and can't be connected to from outside. The solution is to explicitly set the host ip and port to be registered in ZK by setting the advertised.listeners property in server.properties.

提交回复
热议问题