As the title states I am having issues getting my docker client to connect to the docker broker
Errors:
%3|1647161877.851|FAIL|fc24c271e73f#producer-1| [thrd:localhost:9092/bootstrap]: localhost:9092/bootstrap: Connect to ipv4#127.0.0.1:9092 failed: Connection refused (after 0ms in state CONNECT, 1 identical error(s) suppressed)
2022-03-13T08:57:57.851241551Z %3|1647161877.851|ERROR|fc24c271e73f#producer-1| [thrd:app]: fc24c271e73f#producer-1: localhost:9092/bootstrap: Connect to ipv4#127.0.0.1:9092 failed: Connection refused (after 0ms in state CONNECT, 1 identical error(s) suppressed)
Server setup: Community docker-compose.yml from step 1 of guide:
https://docs.confluent.io/platform/current/quickstart/ce-docker-quickstart.html
Client setup:
.NET Confluent.Kafka producer
Procedures so far:
I initially thought it would be an issue with localhost in the docker container and using docker option:
--net=host
also fixed the issue. However this has the side effect of removing published ports and is no good.
I then tried using
--add-host host.docker.internal:host-gateway
which I found in another post (cannot remember which) however this does not work. I initially thought there was an issue with it since the --net=host works but when I tried it with a SignalR sample project it worked straight away.
I have come across multiple posts suggesting changes to
KAFKA_ADVERTISED_LISTENERS
However I find it odd that the host forwarding is not working and changes to this would make a difference. I have nonethelss tried out multiple combinations of it whether it be the broker ip of localhost to 0.0.0.0 etc. (stuff I found across different posts) but with no success.
Trying to get a better understanding of what is going on I came across this post:
https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
Which explains the 2 step process involved in connecting to a broker. Looking at the errors I received with the /bootstrap it seems to already fail on the initial connection. This however should be an indication that the immediate issue is not with with KAFKA_ADVERTISED_LISTENERS however I may be wrong in that assumption.
The post does have a docker to docker scenario but that is being done using custom network bridge which I do not want to have to use for this.
Anybody has any ideas of what I should do? Perhaps knows the exact changes to make and where.