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?
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"
]
})