Can't send Kafka messages though topic and producer both exist


I’m working in TypeScript with the KafkaJS library locally, with a single kafka broker. I’ve connected a producer successfully, have verified that my topic was created, and am generating messages with:

  const changeMessage = {
    key: id,
    value: JSON.stringify(person),
    headers: {
      changeType: status,

Now when I go to send the message:

  try {
    const sendResponse = await producer.send({
      topic: topicName2,
      messages: [changeMessage],
      { id, topicName2 },
      `Sending changed/added person ${id} to topic ${topicName2}`
  } catch (error) {
    { error }, `Could not send personChangedAdded ${id} to topic ${topicName2}`

Here’s the error that I get back:

Could not send personChange to topic topicName2
    error: {
      "name": "KafkaJSError",
      "retriable": true


I had failed to define log.responseFragment(), and when I changed it to a simple the problem was resolved.

Answered By – mojones101

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published