SOHU-Co/kafka-node

Can I add protocol when specifying kafkaHost?

vadymrybak opened this issue · 2 comments

export const kafka_client: KafkaClient = new KafkaClient({
    kafkaHost: 'confluent-cp-kafka:9092'
    connectTimeout: 2000,
    requestTimeout: 10000,
    autoConnect: true,
    connectRetryOptions: {
        maxTimeout: 2000,
        minTimeout: 2000,
        retries: 0
    }
});

When I put full URL in kafkaHost, for example, "https://confluent-cp-kafka:9092", client throws error. Is there any way to add it?

Not in host but you have different way of doing it:

var kafkaClientOption = {
  clientId: 'kafkaadmin',
  kafkaHost : 'broker1:9092,broker2:9092,broker3:9092',
  ssl: true,
  sslOptions: {
    rejectUnauthorized: false,
    ca: [fs.readFileSync('./bin/chain.pem', 'utf-8')],
    cert: [fs.readFileSync('./bin/kafkaadmin.pem', 'utf-8')],
    key: [fs.readFileSync('./bin/kafkaadmin.key', 'utf-8')],
    passphrase: "mypass",
  },
  autoConnect: true,
  connectTimeout: 1000,
  requestTimeout: 1000
}

var client = new kafka.KafkaClient( kafkaClientOption );

(copied from #1185 )

it does not look like kafkaCLient has "ssl" param...