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.
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}};
}
}