1

I am using pykafka, I can get topic names but I cant send message. My code is shown below

client = KafkaClient(hosts='xx.xx.xx.xx:9092')
topic = client.topics['test']
producer = topic.get_sync_producer()
producer.produce(b"message") 

And I get this error message

raise ProduceFailureError("Delivery report not received after timeout")
pykafka.exceptions.ProduceFailureError: Delivery report not received after timeout 
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Coder
  • 31
  • 10

1 Answers1

0
    broker.id=1
    listeners=PLAINTEXT://localhost:9092 

I am sending to an external IP message

If you are setting hosts=some.external.IP:9092, then you need to edit Kafka properties with advertised.listeners=PLAINTEXT://some.external.IP:9092 and make listeners=PLAINTEXT://:9092 to listen on external interfaces.

Listing the topics uses a different protocol, which is why it works fine.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • You mean I need to write as client = KafkaClient(hosts='externalmachineIP:9092') for producer. And for consumer advertised.listeners=PLAINTEXT://locahost:9092 and listeners=PLAINTEXT://localhost:9092 – Coder Nov 26 '19 at 20:14
  • No changes should be needed to your code. You need to update the server.properties file and restart kafka – OneCricketeer Nov 26 '19 at 20:21