I am trying to run a script on a jump host remotely (node) to connect to MSK Kafka brokers in AWS. To reach the broker, I map a local port to a broker and port via an SSH Tunnel using AWS SSM, and then try to connect to the broker in KafkaJS using
ssl: {
checkServerIdentity: () => undefined
},
brokers: ['localhost:9098']
The connection as such works, but I get an error saying "Hostname verification failed". If I run the node script on the jump host itself passing the broker:port instead of localhost:9098, the script works fine.
How could I circumvent this "hostname verification failed" error?
Thank you
SSH Port forwarding wont work with Kafka unless you explicitly modify the
advertised.listeners
to allow this (which I dont think MSK lets you edit)https://www.confluent.io/blog/kafka-listeners-explained/
If your jump host is within the VPC, you can just connect directly instead of trying to tunnel
https://kafka.js.org/docs/configuration#aws-iam-example