- Newest
- Most votes
- Most comments
Based on your description, there are several potential causes for the timeout error when connecting from EMR Spark to MSK with IAM authentication.
First, ensure you've included the aws-msk-iam-auth library in your dependencies. This is a critical component when using IAM authentication with MSK. You mentioned several jars, but this specific one wasn't listed. You can include it in your Spark submit command with:
--packages software.amazon.msk:aws-msk-iam-auth:<version>
Second, check your security group configurations. Even if you can connect via telnet, Spark executors might be running on different nodes with different security group rules. Ensure the security group attached to your EMR cluster allows outbound traffic to the MSK cluster, and the MSK cluster's security group allows inbound traffic from the EMR security group on port 9098.
Third, verify that your EMR application is configured with proper VPC access. When using the Kafka connector with IAM authentication for MSK, your EMR Serverless application must have VPC access configured. The subnets must have network connectivity to access the Kafka cluster and should have internet access through a NAT Gateway to download the Maven dependencies.
Fourth, double-check your Kafka configuration properties. The key properties for MSK IAM authentication should be:
kafka.security.protocol = SASL_SSL
kafka.sasl.mechanism = AWS_MSK_IAM
kafka.sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required;
kafka.sasl.client.callback.handler.class = software.amazon.msk.auth.iam.IAMClientCallbackHandler
Finally, if you're using EMR Serverless, ensure your job execution role has the necessary permissions to interact with MSK. The role should have permissions like kafka-cluster:Connect, kafka-cluster:DescribeCluster, kafka-cluster:ReadData, and kafka-cluster:DescribeTopic.
If all these configurations are correct and you're still experiencing issues, consider enabling more detailed logging for the Kafka client to get more insights into the connection problems.
Sources
Build a secure serverless streaming pipeline with Amazon MSK Serverless, Amazon EMR Serverless and IAM | AWS Big Data Blog
msk connector not able to fetchdata from msk cluster.. timeout error INFO [AdminClient clientId=adminclient-1] Metadata update failed (org.apache.kafka.clients.admin.internals.AdminMetadataManager:23 | AWS re:Post
Supported streaming connectors - Amazon EMR
Connect to AWS MSK cluster from Local mac | AWS re:Post
Relevant content
asked 5 years ago
asked 3 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 2 years ago
