I am trying to send some messages to a Kafka topic in Machine_2
through a python script in Machine_1
. Both Machine_2
and Machine_1
are in the same network and both are VM's in Azure.
Code: sampl.py
from kafka import KafkaProducer
Producer = KafkaProducer(bootstrap_servers=['Machine_2:9092'])
Producer.send('test', 'hello')
If I run the above code as
python sampl.py
There is no messages reaching to the Machine_2
. However, If I do:
python -i sampl.py
Then the messages reach to the Machine_2
. I checked the same using kafka-console-consumer.sh
. I did yum update
in Machine_1
thinking there might be some libraries missing here. But no luck yet.
Thanks.