I created a cluster with 2 brokers in MSK but I cant connect using kafkajs client. I keep getting this connection timeout error
{"level":"ERROR","timestamp":"2021-07-29T13:35:35.625Z","logger":"kafkajs","message":"[Connection] Connection timeout","broker":"{broker1}","clientId":"order-app"} {"level":"ERROR","timestamp":"2021-07-29T13:35:35.627Z","logger":"kafkajs","message":"[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout","retryCount":0,"retryTime":251}
For more information in cluster config I used Access control method of none and TLS encryption is enabled (plain text is not). I tried ports 9092 and 9094. I set the inbound rule to all traffic just for testing and it still seems to timeout. Also tried with ssl enabled and disabled but same results.
const { Kafka } = require('kafkajs')
const kafka = new Kafka({
clientId: 'order-app',
brokers: [
'broker1:port',
'broker2:port',
],
ssl: true,
})