I have an MSK cluster in which i have used AWS IAM authentication .When i am telnet to the broker:9098
, the broker gets connected .But when am passing the same broker:9098
in a node app's kafka producer code, it shows "The broker does not support the requested SASL mechanism"
.
my kafka producer code goes like:
const { Kafka,logLevel } = require('kafkajs');
const kafka = new Kafka({
clientId: 'api_gateway_client',
brokers: ["b-2.ashxxxxx.xx74.cx.kafka.ap-southeast-1.amazonaws.com:9098"],
ssl: true,
sasl: {
mechanism: 'aws',
authorizationIdentity: '8829xxx97', // UserId or RoleId
accessKeyId: 'AKIA4xxxxxGD37NEJ',
secretAccessKey: 'q7SI3xxxxxxiAou6TDXWdyR6h',
//sessionToken: 'WHArYt8i5vfQUrIxxxxxeL9tgQMJp6QFNEXAMPLETOKEN' // Optional
},
})
const producer = kafka.producer();
producer.connect();
export async function sendKafkaMessage(topic: string, message: string): Promise<any> {
const result = await producer.send({
topic,
messages: [
{ value: message }
]
});
return result;
}
producer.on('producer.connect',async () => {
console.log('Kafka producer connected ................');
const admin = kafka.admin();
const topic = "geolah"
const result = await producer.send({
topic,
messages: [
{ value: "hii TOPIC" }
]
});
});