
That means that our client is going to be using localhost to try to connect to a broker when producing and consuming messages. But note that the BrokerMetadata we get back shows that there is one broker, with a hostname of localhost. In this example, my client is running on my laptop, connecting to Kafka running on another machine on my LAN called asgard03: This could be a machine on your local network, or perhaps running on cloud infrastructure such as Amazon Web Services (AWS), Microsoft Azure, or Google Cloud Platform (GCP). Now let’s check the connection to a Kafka broker running on another machine.

Scenario 1: Client and Kafka running on the different machines

Note: The broker metadata returned is 192.168.10.83, but since that’s the IP of my local machine, it works just fine. My Python client is connecting with a bootstrap server setting of localhost:9092. Scenario 0: Client and Kafka running on the same local machineįor this example, I’m running Confluent Platform on my local machine, but you can also run this on any other Kafka distribution you care to. Your client would bootstrap against one (or more) of these, and that broker would return the metadata of each of the brokers in the cluster to the client. In practice, you’d have a minimum of three brokers in your cluster. Just one broker?Īll these examples are using just one broker, which is fine for a sandbox but utterly useless for anything approaching a real environment.
#Docker for mac kafka how to
This article will walk through some common scenarios and explain how to fix each one.

It’s written using Python with librdkafka ( confluent_kafka), but the principle applies to clients across all languages. To read more about the protocol, see the docs, as well as this previous article that I wrote.īelow, I use a client connecting to Kafka in various permutations of deployment topology. The broker details returned in step 1 are defined by the advertised.listeners setting of the broker(s) and must be resolvable and accessible from the client machine. What sometimes happens is that people focus on only step 1 above, and get caught out by step 2.

If the broker has not been configured correctly, the connections will fail. The client then connects to one (or more) of the brokers returned in the first step as required.This returns metadata to the client, including a list of all the brokers in the cluster and their connection endpoints. The initial connection to a broker (the bootstrap).When a client wants to send or receive a message from Apache Kafka ®, there are two types of connection that must succeed:
