Hi James, As suggested, I did try below steps but still my producer is unable to connect with the consumer. Below are the changes checked upon:
*Producer changes* In My java producer configuration class which is at client network and different system, Changed the configuration of bootstrap server from localhost to IP address of the system wherein my consumer and kafka server is present configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "000.000.0.000:9092"); - IP Address of SERVER_HOSTNAME.com: *Server Changes:* The Server changes which is on a different network and system.Made changes to the advertised.listeners=PLAINTEXT://SERVER_HOSTNAME.com:9092 SERVER_HOSTNAME is the hostname of the system where the kafka server and consumer both are Present. After making these changes, restarted zookeeper and kafka server. After making the above changes, When the producer application in java is started , the producer throws the below exception When I try sending the data to the producer through a API created for the same purpose. 2022-09-28 17:32:23.626 WARN 24404 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Error connecting to node SERVER_HOSTNAME.com:9092 (id: 0 rack: null) java.net.UnknownHostException: SERVER_HOSTNAME.com at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:800) ~[na:na] at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1507) ~[na:na] at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1366) ~[na:na] at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1300) ~[na:na] at org.apache.kafka.clients.DefaultHostResolver.resolve(DefaultHostResolver.java:27) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:111) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.currentAddress(ClusterConnectionStates.java:512) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.access$200(ClusterConnectionStates.java:466) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.ClusterConnectionStates.currentAddress(ClusterConnectionStates.java:172) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:1004) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.NetworkClient.access$600(NetworkClient.java:75) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1177) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1065) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:561) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:325) ~[kafka-clients-2.7.1.jar:na] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:240) ~[kafka-clients-2.7.1.jar:na] at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na] Is there something wrong in the configuration? Or Have I missed out on any of them that might be required. Could you please advise on this. Thanks in Advance, Namita On Tue, Sep 27, 2022 at 7:35 PM James Ziesig <james.zie...@broadcom.com.invalid> wrote: > Hi Namita, > > This is likely a listener configuration issue. The bootstrap > server setting only gets you so far, your client must be able to contact > the server via a listener address. I have seen this occur on a few systems > where a hostname could not be identified by Kafka, so the server advertises > a listener on only localhost:9092. Since your producer is not on the same > system, it will not connect. > > You can try updating the listeners and advertised.listeners properties in > your server configuration file to use the actual hostname (assuming the > producer can reach the server via the hostname). > > Example (assumes plaintext communication, replace PLAINTEXT if needed): > listeners=PLAINTEXT://myserver.acme.com:9092 > advertised.listeners=PLAINTEXT://myserver.acme.com:9092 > > I hope this helps, > > Jim Ziesig > > On Tue, Sep 27, 2022 at 3:25 AM Namita Jaokar <jaokarnami...@gmail.com> > wrote: > >> Hi All, >> >> I am currently exploring a scenario where my producer and consumer are at >> different networks and systems. >> >> Below is my scenario: >> >> My kafka producer is on a client network on a system that does not have >> Apache kafka installed. >> My Kafka consumer is on my network and my system. >> I have the zookeeper and kafka server setup at the consumer system. >> I want the producer to send data to the consumer which is on my network. I >> have tried this case in my spring boot application. >> It gives me an error stating [Producer clientId=producer-1] Connection to >> node -1 (localhost/127.0.0.1:9092) could not be established. Broker may >> not >> be available. >> >> How will I let my producer and consumer communicate in this case? >> What configurations are required to establish the connection between the >> two. >> Please advise. >> >> Thanks & Regards, >> Namita Jaokar >> > > This electronic communication and the information and any files > transmitted with it, or attached to it, are confidential and are intended > solely for the use of the individual or entity to whom it is addressed and > may contain information that is confidential, legally privileged, protected > by privacy laws, or otherwise restricted from disclosure to anyone else. If > you are not the intended recipient or the person responsible for delivering > the e-mail to the intended recipient, you are hereby notified that any use, > copying, distributing, dissemination, forwarding, printing, or copying of > this e-mail is strictly prohibited. If you received this e-mail in error, > please return the e-mail to the sender, delete it from your computer, and > destroy any printed copy of it.