Support Questions

Find answers, ask questions, and share your expertise

Kafka Remote Producer - advertised.listeners

New Contributor

Hi all,

I am running Kafka 0.10.0 on CDH 5.9, cluster is kerborized.
What I am trying to do is to write messages from a remote machine to my Kafka broker.
The cluster (where Kafka is installed) has internal as well as external IP addresses.
The machines' hostnames within the cluster get resolved to the private IPs, the remote machine resolves the same hostnames to the public IP addreses.
I opened the necessary port 9092 (I am using SASL_PLAINTEXT protocol) from remote machine to Kafka Broker, verified that using telnet.

First Step - in addition to the standard properties for the Kafka Broker, I configured the following:

-> I am able to start the console consumer with
kafka-console-consumer --new-consumer --topic <topicname> --from-beginning --bootstrap-server <hostname>:9092 --consumer.config

-> I am able to use my custom producer from another machine within the cluster
relevant excerpt of producer properties:

-> I am not able to use my custom producer from the remote machine,
Exception org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for <topicname>-<partition>
using the same producer properties. I am able to telnet the Kafka Broker from the machine and /etc/hosts includes hostnames and public IPs.

Second Step - I modified
consumer & producer within the same cluster still run fine (bootstrap servers are now the internal IP with port 9092), as expected remote producer fails (but that is obvious given that it is not aware of the internal IP addresses)

Third Step - where it gets hairy 😞

-> starting my consumer with
kafka-console-consumer --new-consumer --topic <topicname> --from-beginning --bootstrap-server <hostname>:9092 --consumer.config

(Just a warning, but I don't think this is right...)
WARN clients.NetworkClient: Error while fetching metadata with correlation id 1 : {<topicname>=LEADER_NOT_AVAILABLE}

-> starting my consumer with
kafka-console-consumer --new-consumer --topic <topicname> --from-beginning --bootstrap-server <KafkaBrokerPublicIP>:9092 --consumer.config

it just hangs after those log messages:
INFO utils.AppInfoParser: Kafka version : 0.10.0-kafka-2.1.0
INFO utils.AppInfoParser: Kafka commitId : unknown

seems like it cannot find a coordinator as in the normal flow this would be the next log:
INFO internals.AbstractCoordinator: Discovered coordinator <hostname>:9092 (id: <someNumber> rack: null) for group console-consumer-<someNumber>.

-> starting the producer on a cluster node with bootstrap.servers=<hostname>:9092
I observe the same as with the producer:
WARN NetworkClient:600 - Error while fetching metadata with correlation id 0 : {<topicname>=LEADER_NOT_AVAILABLE}

-> starting the producer on a cluster node with bootstrap.servers=<KafkaBrokerPublicIP>:9092 I get
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

-> starting the producer on my remote machine with either bootstrap.servers=<hostname>:9092 or bootstrap.servers=<KafkaBrokerPublicIP>:9092 I get
NetworkClient:600 - Error while fetching metadata with correlation id 0 : {<topicname>=LEADER_NOT_AVAILABLE}

I have been struggling for the past three days to get this to work, however I am out of ideas 😕 My understanding is that advertised.hostnames serves for exactly this purpose, however either I am doing something wrong, or there is something wrong in the machine setup.

Any hints are very much appreciated!


Super Collaborator
You could have an issue with certificates...if you enable DEBUG for the client, you should be able to determine what it's having issues with:

cp /etc/kafka/conf/ /var/tmp
sed -i -e 's/INFO/DEBUG/g' /var/tmp/
export KAFKA_OPTS="-Dlog4j.configuration=file:/var/tmp/"