Once the Kafka deployment is complete, the Kafka and zookeeper are deployed on the same machine because it is a single-unit deployment test.
Once deployed, you can use the command line to test producers and consumers,
However, when accessing using the Java API, it is always impossible to connect,
And the following error is indicated:
kafka.common.FailedToSendMessageException:Failed to send messages after 3 tries.
、
Toss for a long time, the original is because the connection when the host can not find the cause of
Workaround:
Modify the Kafka configuration file server.properties
Set the appropriate host IP 192.168.1.114 configuration as follows:
zookeeper.connect=192.168.1.114:2181
advertised.listeners=plaintext://192.168.1.114:9092
Once setup is complete, restart Kafka to connect.
Note:
There is also a problem, is the Java API to Kafka connection when stuck, also this problem, through the above configuration of IP, can not only solve the problem of stuck, may connect Kafka