[英]How to connect Kafka consumer with SSL setup with any of Node JS modules
I want to connect external kafka topic provided by vendor; 我想连接供应商提供的外部kafka主题; as we are already developed service on top of Node JS.
因为我们已经在Node JS上开发了服务。
So I am looking for 所以我在寻找
NodeJS kafka consumer and with SSL setup;
NodeJS kafka消费者和SSL设置;
as the kafka-server needs the details while handshake; 因为kafka-server需要握手时的细节;
This what I tried with kafkajs
module already 这就是我用
kafkajs
模块尝试过的
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;
连接错误:101057795:错误:1408E0F4:SSL例程:ssl3_get_message:意外消息:openssl \\ ssl \\ s3_both.c:408:\\连接时;
Could you please help me with resolution or suggest me any npm module, so that I can give a try examples are so welcome. 你能帮我解决一下或建议我任何npm模块,这样我就可以尝试一些例子了。
Forgot to add key
attribute in ssl
Options; 忘了在
ssl
选项中添加key
属性; as this one is the mandatory while handshake; 因为这是握手时的强制性;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.