Your SQS consumer can hang forever by default, and the one timeout that fixes it

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

The AWS Rust SDK allows SQS long-poll receive calls to hang indefinitely when a TCP connection is silently dropped by a load balancer or NAT gateway. Since the default SDK configuration only bounds connection establishment — not in-flight requests — a stalled receive never resolves, parking the entire sequential fetch loop and causing the queue to back up while the consumer appears healthy. The fix is setting an `operation_attempt_timeout` slightly above the long-poll wait time (20s + 10s headroom = 30s), which causes stalled attempts to fail and retry on a fresh connection rather than hanging forever. The distinction between `operation_attempt_timeout` (per HTTP attempt) and `operation_timeout` (entire operation including retries) is critical: only the per-attempt variant allows recovery via retry rather than giving up entirely. This issue is known to the AWS SDK team and the default is not being changed, so any service long-polling SQS with this SDK must set the timeout manually.

5m read timeFrom encore.dev
Post cover image
Table of contents
How the subscriber reads the queueWhy the whole subscription stallsThe timeout that fixes itWhy it has to be a per-attempt timeoutAny long-polling client
122.6K Impressions4 Comments