0

As described in a doc https://kafka.js.org/docs/configuration the client must be configured with at least one broker.

const { Kafka } = require('kafkajs')

let kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['kafka1:9092', 'kafka2:9092']
})

With kafka client initiated I want to go ahead and update its ssl settings. Is there a way to update kafka client by specifying its ssl values or I would need to re-declare the kafka variable, like so:

kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['kafka1:9092', 'kafka2:9092'],
  // authenticationTimeout: 10000,
  // reauthenticationThreshold: 10000,
  ssl: true,
  sasl: {
    mechanism: 'plain',
    username: 'my-username',
    password: 'my-password'
  },
})
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
  • What happens when you try to edit `kafka.ssl`? Specifically, it should only be modifiable until you call `.connect()` on some client. – OneCricketeer Sep 08 '22 at 22:48
  • Unfortunately `kafka` object doesn't have a property `ssl` – alphanumeric Sep 09 '22 at 16:04
  • Not sure what you mean? In the second block, you have `Kafka({ ... ssl: {} })`. It may be `kafka.options.ssl` - https://github.com/tulios/kafkajs/blob/master/src/index.js#L40 – OneCricketeer Sep 09 '22 at 16:27

0 Answers0