I'm sending messages to a queue from a lambda function. But some times sqs.sendMessage dont return anything and the lambda get timeout. This happens sometimes
I tried changing de code many times, to work with await, promises and callback but the error persist.
Lambda log
const sqs = new aws.SQS({apiVersion: '2012-11-05'});
//TODO: Validar campos obrigatórios nas mensagens de acordo com o tipo de mensagem
exports.sendMessage = async (message) => {
let params = {
MessageBody: JSON.stringify(message),
QueueUrl: 'https://sqs.us-east-1.amazonaws.com/....',
};
try {
await sqs.sendMessage(params).promise();
return {statusCode: 200, body: {data: "Notification sent successfully"}};
} catch (e) {
return {statusCode: 400, body: {data: e}};
}
}
I had a similar issues. What I did to make it work was add in the endpoint url into the boto3 client call.
For Example: boto3.client('sqs',endpoint_url='https://YourVPCDNSEndpointforSQS')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With