0

The Django server is going stuck if Kafka-comsumer starts. What should I do? I want to run this consumer as a sidecar container. Can anyone help me?

consumer = KafkaConsumer("my-topic", bootstrap_servers=\['{}:{}'.format(HOST, PORT)\],auto_offset_reset="earliest", value_deserializer=lambda x: ReadHelper().json_deserializer(x), group_id="my_consumer_group" )
for msg in consumer:
print(msg)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    Please add more details like where is the Django server running, what is the value of HOST and PORT variables, is the Django application getting stuck when connecting to Kafka, etc. – Abhishek S Nov 29 '22 at 06:04
  • 1
    HOST=localhost, PORT=9092; Server is running in docker. Connection is not a problem means the consumer is working fine but when I started the server using gunicorn, here gunicorn was stuck and not started completely. – Abhay Braja Nov 29 '22 at 06:11
  • 1
    If the Django server is running in a Docker and you use `localhost` to connect to kafka, it will not work. Instead, you have to give kafka docker's name / the host server's IP (where kafka docker is running) – Abhishek S Nov 29 '22 at 06:20

0 Answers0