Open
Description
Dear everybody,
I have kafka running on AWS EC2 instance at private IP addr: 'XX.XX.XX.XX'. The instance id is 'ABCDEF', VPC id is 'vpc-YYYYYYY'.
In that, i've created topic 'new-topic'.
I've tested publish message to kafka by producer console and check message by consumer console is OK (as LOCALHOST:9092).
I want publish message from Lambda function to Kafka on this EC2 instance server.
In the AWS lambda function(by Python) I write this code:
from kafka import KafkaProducer
def lambda_handler(event, context):
# create kafka Producer
kafka_producer=KafkaProducer(bootstrap_servers=['XX.XX.XX.XX:9092'],
api_version=(0, 11))
#send message to Kafka
kafka_producer.send('new-topic', b'hello from python lambda')
I'v add this lambda function to VPC id 'vpc-YYYYYYY' the EC2 running. and config Role, Policy...
But, when I run test the lambda function, only error message response:
Response:
{
"errorMessage": "..... Task timed out after 10.01 seconds"
}
I don't know why. Can anyone help me?
Thank you so much!