I'm trying to create a Kafka
cluster to send messages to a remote control. I have configured everything as described here.
I am running this on a Linux red hat
machine, and it works fine using the shell. After writing the java code as described in the quick start
tutorial on my windows machine, I have received the following error:
...
DEBUG kafka.client.ClientUtils$ - Successfully fetched metadata for 1 topic(s) Set(example)
...
ERROR kafka.producer.SyncProducer - Producer connection to cldExampleKafka.domain:80 unsuccessful
java.nio.channels.UnresolvedAddressException
...
at kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:44)
...
WARN kafka.producer.async.DefaultEventHandler - Failed to send producer request with correlation id 2 to broker 0 with data for patitions [ati,0]
java.nio.channels.UnresolvedAddressException
...
kafka.common.FailedToSendMessageException: Failed to send message after 3 tries.
I have also tried to run the jar in a different Linux machine, and still received the same error.
Changing the address to localhost
and running the java code as a jar in the machine where the kafka is installed works.
I believe it something with the configuration, but I couldn't find it.
Tried connecting to kafka remote cluster from my local machine.
VM's had one internal (9.0.0.1) and one external IP (192.1.1.1). I could ssh only to the internal & not the external. I did these changes to my conifg/server.properties:
//set to the IP of the machine (find using
ifconfig
orhostname -I
)//set to the IP the consumer and producer will connect
in
config/server.properties
I put this
listeners=PLAINTEXT://[server_ip]:9092
and it worked fine.
For quick testing, don't forget to use [server_ip] in the command line of kafka-consumer. Example:
I hope this may help you.
Regards Ali
In your kafka
server.properties
there is a commented configurationUncomment this and add the IP of the Linux Machine in which kafka is running.
And connect from clients to
<Kafka Running Machine IP>
This should fix your issue.EDIT
Optionally you can uncomment the
Also if you are listening on a different port than the default one.
Worked with
from
server.properties
UncommentAnd
Replace
<HOST IP>
with actual IP.