I have a Cloudwatch Events Rule that periodically invokes an AWS Lambda. This Lambda attempts to pull a message from an AWS SQS queue using the receiveMessage SDK method. Then, if there is a message, it invokes an AWS Step Function. This process works when invoked locally. However, when Cloudwatch triggers it, I receive the error Client network socket disconnected before secure TLS connection was established. See my code below:
module.exports.triggerStepFunction = () => {
let sqs = new AWS.SQS({apiVersion: '2012-11-05'})
let params = {
QueueUrl: 'my_endpoint',
AttributeNames: [
'All'
],
MessageAttributeNames: [
'All'
],
MaxNumberOfMessages: 1,
ReceiveRequestAttemptId: Date.now().toString(),
VisibilityTimeout: 10,
WaitTimeSeconds: 6
}
sqs.receiveMessage(params, function(err, receiveMessageData) {
if (err) {
return err
} else {
return receiveMessageData
}
})
}
What is happening and how do I fix it?