I want to connect external kafka topic provided by vendor; as we are already developed service on top of Node JS.
So I am looking for
NodeJS kafka consumer and with SSL setup;
as the kafka-server needs the details while handshake;
This what I tried with kafkajs
module already
var fs = require('fs');
var Kafka = require('kafkajs').Kafka;
var logLevel = require('kafkajs').logLevel;
var _kafka = new Kafka({
clientId: 'my-app',
brokers: ['broker:9093'],
logLevel: logLevel.DEBUG,
ssl: {
rejectUnauthorized: false,
ca: [fs.readFileSync('./cert/ca.trust.certificate.pem', 'utf-8')],
cert: fs.readFileSync('./cert/client-cert-signed.pem', 'utf-8'),
}
});
try {
const consumer = _kafka.consumer({ groupId: 'test-group' }, { maxWaitTimeInMs: 3000 });
consumer.connect();
consumer.subscribe({ topic: 'external-topic', fromBeginning: true });
consumer.run({
eachMessage: async({ topic, partition, message }) => {
console.log({
partition: 2,
offset: message.offset,
value: message.value.toString(),
})
},
})
} catch (err) {
console.log('Error while connect : ' + err);
}
It is giving
Connection error: 101057795:error:1408E0F4:SSL routines:ssl3_get_message:unexpected message:openssl\\ssl\\s3_both.c:408:\\ while connecting;
Could you please help me with resolution or suggest me any npm module, so that I can give a try examples are so welcome.
Forgot to add key
attribute in ssl
Options; as this one is the mandatory while handshake;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.