ECONNRESET when sending message to SQS from Lambda

0

Hi, I'm developing a custom events scheduler service that is built on top of Lambda (Node), DynamoDB and SQS. During testing, I encountered a recurring "Timeout Error ECONNRESET" when attempting to send messages to SQS.

Context

My setup involves a "scheduler" Lambda function that executes every minute to retrieve events scheduled for dispatch within the next 10 minutes from DynamoDB. These events are then enqueued in an SQS queue using a sendMessage call, with a delay set until their scheduled dispatch time. Subsequently, a "dispatcher" Lambda function consumes these messages to dispatch events to an EventBridge bus. To stress-test the system, I've been manually creating events scheduled for simultaneous emission.

My issue

The problem arises when I attempt to enqueue over approximately 2000 messages to the SQS "dispatcher" queue. At this point, the SDK throws TimeoutError ECONNRESET when sending messages to SQS, typically after three internal attempts. Each Lambda execution sends a maximum of 25 messages in parallel, and the volume of messages does not seem substantial enough to exceed SQS limitations. However, I am struggling to understand why this error occurs so frequently.

Additional information

  • Region : eu-central-1
  • Lambda Node.js 20.x
  • AWS SDK v3
Pierre
已提问 1 个月前174 查看次数
1 回答
0

Not sure why you are receiving these errors. I do not think the issue is with SQS capacity, it more looks like some issue on the client side. Maybe you should retry if this happens?

Saying that, why aren't you using EventBridge Scheduler, which can handle millions of recurring and one time events. No need for you DDB table, the function that wakes up every minute and the queue. EB Scheduler can invoke your dispatcher function directly.

profile pictureAWS
专家
Uri
已回答 1 个月前
  • Thanks for your answer, I revamped my implementation to avoid sending too many message in the same lambda process and used batching to reduce SQS calls it looks like I do not have the ECONNRESET error anymore.

    Unfortunately EventBridge Scheduler doesn't totally fit my needs since it has a 60-second precision and for the purpose of my application I need something closer to a 1-second precision. But maybe combined with a sleep function in the dispatcher it could do the job, I'll further dig into it to!

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则