Rene B.
Rene B.

Reputation: 7424

Failed to connect to seed broker with kafkajs

I am trying to use kafkajs in order to create a kafka consumer. However, I get already an error when connecting to kafka:

"[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Closed connection"

This is the code I am using:

const { Kafka } = require('kafkajs')

const kafka = new Kafka({
  clientId: 'my-app',
  brokers: [
      "abc123f.xyz.cde.net:9094",
      "abc123h.xyz.cde.net:9094",
      "abc123k.xyz.cde.net:9094"
      ]
})

Does anyone has an idea why this error happens or how to solve it?

Upvotes: 7

Views: 31912

Answers (1)

Rene B.
Rene B.

Reputation: 7424

In the end it was the missing ssl: true parameter. The solution was as follows:

const { Kafka } = require('kafkajs')

const kafka = new Kafka({
  clientId: 'my-app',
  ssl: true,
  brokers: [
      "abc123f.xyz.cde.net:9094",
      "abc123h.xyz.cde.net:9094",
      "abc123k.xyz.cde.net:9094"
      ]
})

Upvotes: 16

Related Questions