I'm running Confluent Platform in wsl 2(Ubuntu Distribution) and I also running a Spring application on Windows but when I send a message with a producer I have this error:
Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected
I have a look this articles: https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/ and https://forum.confluent.io/t/running-kafka-connect-sink-on-separate-machine-from-zookeeper-topic-non-localhost/3038 and https://www.confluent.io/blog/kafka-listeners-explained/
But I don't find the solution.
What is the configuration in concluent/etc/kafka/server.properties file?
I've set this:
advertised.listeners=PLAINTEXT://127.0.0.1:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT
listeners=PLAINTEXT://0.0.0.0:9092
Kafka is running on: "localhost:9092" and within WSL2 I can send and read messages correctly but it doesn't work my spring boot application on Windows.
I see this answer, but It doesn't work in my localhost: running Kafka on WSL and make producer on windows
Do I have to change something in my Windows configuration? In C:\Windows\System32\drivers\etc\hosts?
Could you please advice how to solve this error? Thanks in advance!