1
votes

I'm running zookeeper, kafka servers along with a consumer client on a windows machine. When I use a simple producer program in python or c++ in a different machine also running windows, everything works normal. However, when I use the same producer program in a linux machine it does not work, it accuses failed to resolve . All computers are connected on the same network. I have tried to set the listeners and advertised.listeners in the kafka server.properties in several different manners, but with the same result.

Machine running windows with servers and consumer:

IP:192.168.0.149
hostname:something

second Machine running linux or windows (dual boot) with the producer program:

IP:192.168.0.150
hostame:somethingelse

some tried configurations at server.properties:

1 listeners=PLAINTEXT:\0.0.0.0:9092 advertised.listeners=PLAINTEXT:\something:9092

producer at second machine:

producer = KafkaProducer(bootstrap_servers=['192.168.0.149:9092'])

works on windows, does no work on linux

2 listeners=PLAINTEXT:\localhost:9092 advertised.listeners=PLAINTEXT:\something:9092

producer at second machine:

producer = KafkaProducer(bootstrap_servers=['192.168.0.149:9092'])

works on windows, does no work on linux

3 #listeners= #advertised.listeners=

producer at second machine:

producer = KafkaProducer(bootstrap_servers=['192.168.0.149:9092'])

works on windows, does no work on linux

4 listeners=PLAINTEXT:\192.168.0.149:9092 advertised.listeners=PLAINTEXT:\something:9092

producer at second machine:

producer = KafkaProducer(bootstrap_servers=['192.168.0.149:9092'])

works on windows if consumer passes the ip instead of localhost, does no work on linux

1

1 Answers

0
votes

Listeners should always stay as 0.0.0.0. This is the bind address to accept all external connections

If you want to run Kafka on windows, you need to deal with the windows firewall. Try disabling it while testing connections. It would probably be best that you switch the broker to run on Linux.

The advertised listeners should only be the hostname if both systems are able to resolve each other by DNS name. Otherwise, save yourself the extra network hop and use the IP as the advertised listener. If you're getting "failed to resolve", seems like a DNS issue, and ping windows-host shouldn't work either

To debug your connection, I would suggest using kafkacat

kafkacat -b kafka-host:9092 -L