kafkajs icon indicating copy to clipboard operation
kafkajs copied to clipboard

retry does not work when the error is [Broker not connected]

Open chen-zhihang opened this issue 3 years ago • 2 comments

Describe the bug

I am using 1.14.0 on production. and configure kafka as the following

const kafka = new Kafka({
  clientId: "myClientId",
  brokers: "localhost:9092",
  logLevel: logLevel.WARN,
  retry: {
    initialRetryTime: 100,
    retries: 10000
  }
})
const producer = kafka.producer({ maxInFlightRequests: 1 })
await producer.connect()
producer.send(
 {topic: "***.***",  messages: "msg"}
)

and expect it could retry many times when error happens. But I saw logs on production. the last log is

{"level":"ERROR","timestamp":"2021-01-22T01:36:46.484Z","logger":"kafkajs","message":"[Producer] Broker not connected","retryCount":1,"retryTime":142}

and it didn't retry.

To Reproduce Please provide either a link to a:

  1. failing test in a KafkaJS fork
  2. repository with an example project reproducing the issue

If none of the above are possible to provide, please write down the exact steps to reproduce the behavior:

  1. Run a producer that continuously produces messages to a topic
  2. Run a consumer that subscribes to that topic and logs each topic offset
  3. After the consumer has consumed 100 messages, it...

Expected behavior

the send message could get retries

Observed behavior A clear and concise description of what did happen. Please include any relevant logs with the log level set to debug.

Environment:

  • OS: [e.g. Mac OS 10.15.3]
  • KafkaJS version: 1.14.0
  • Kafka version [e.g. 2.3.1]
  • NodeJS version [e.g. 10.13.0]

Additional context Add any other context about the problem here.

chen-zhihang avatar Oct 21 '21 08:10 chen-zhihang

The same problem repeats

ezhuo avatar Nov 20 '21 04:11 ezhuo

Same problem here, retry does not occur and an exception is thrown with: "Producer - Broker not connected"

OS: Alpine KafkaJS version: 1.15.0 Kafka version 2.3.1 NodeJS version 16.13

chkp-talron avatar Dec 12 '21 12:12 chkp-talron

I am also experiencing the same issue.

frankgreco avatar Apr 24 '23 01:04 frankgreco