I am using redpanda for testing in docker-compose, when I am using a ephemaral port for 19092 port the external port for kafak is not working and port is open but clients (producer/consumer) couldn't connect, when I change it to expelicit 19092:19092 it works. Do you have any Idea?
reason that why it is happening.
Mostly got to do with your advertise address: (I wrote it since it's an FAQ) https://dzone.com/articles/what-is-advertised-kafka-address
Basically it's because of how docker rewires the network, so you'll need to talk to the port that's providing the correct Kafka advertise address to your consumer and producer, and by default that port is 19092 for RP setting. And for internal RPC within the same docker network you'll use default 9092, without needing to export it.