node.jsapache-kafkakafkajs

This is not the correct coordinator for this group kafka error


I am using kafkajs and getting this error

{"level":"INFO","timestamp":"2022-07-07T08:55:41.859Z","logger":"kafkajs","message":"[Consumer] Starting","groupId":"ReplacerService_9f1296ad-d028-4812-a84f-81cf2743640f"}

{"level":"ERROR","timestamp":"2022-07-07T08:55:49.414Z","logger":"kafkajs","message":"[Consumer] Crash: KafkaJSNumberOfRetriesExceeded: This is not the correct coordinator for this group","groupId":"ReplacerService_9f1296ad-d028-4812-a84f-81cf2743640f","retryCount":5,"stack":"KafkaJSNonRetriableError\n  Caused by: KafkaJSError: This is not the correct coordinator for this group\n    at C:\\Users\\wgupta\\Backend\\AI\\service\\node_modules\\kafkajs\\src\\consumer\\consumerGroup.js:361:17\n    at runMicrotasks (<anonymous>)\n 
 at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async Runner.start 

I am not able to figure out what is the issue This is not the correct coordinator for this group

Broker value - KAFKA_BROKERS="localhost:9092"


Solution

  • I found out that the problem is with logs folder (where meta.properties is stored) So before I launch zookeeper then kafka, I fully empty logs folder. To have everything in one place I just have one bash script

    #!/bin/bash
    
    rm -rf /home/kafka/logs
    mkdir /home/kafka/logs
    sudo systemctl start zookeeper
    sudo systemctl start kafka