0

I want to publish in Kafka topic I am unable to do so, the program halts. I am getting this error:

KafkaTimeoutError: Failed to update metadata after 60.0 secs.

def saveResults(response):
    entities_tweet = response["entities"]
    for entity in entities_tweet:
        try:
            for i in entity_dict:
                for j in entity_dict[i]:
                    if(entity["text"] in j):
                        entity["tweet"] = response["tweet"]
                        entity["tweetId"] = response["tweetId"]
                        entity["timeStamp"] = response["timeStamp"]
                        #entity["userProfile"] = response["userProfile"]
                        future = producer.send('argentina-iceland-june-16-watson', bytes(entity))
                        print("Published.")
                    else:
                        print("All ignored.")
                        future = producer.send('argentina-iceland-june-16-watson', bytes(entity))
                        print("Published")
        except Exception as e:
            print (e)
        finally:
            producer.flush()

However, this is working:

from kafka import KafkaProducer
from kafka.errors import KafkaError

producer = KafkaProducer(bootstrap_servers=['broker1:1234'])

# Asynchronous by default
future = producer.send('my-topic', b'raw_bytes')
hasherBaba
  • 319
  • 5
  • 18

1 Answers1

0

It looks like that you're using incorrect boostrap server, it should be broker1:9092 instead of broker1:1234...

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • changed it No improvement. – hasherBaba Jun 30 '18 at 10:01
  • Check that you actually can reach this hostname/port from machine where you're running your producer – Alex Ott Jun 30 '18 at 10:08
  • I can. Also, the issue is with the multi-threading. Can you help me out, probably give me an example of how to insert data in mongo using python's multithreading? Or should I ask another question for this? – hasherBaba Jun 30 '18 at 10:24