nestjs-sqs icon indicating copy to clipboard operation
nestjs-sqs copied to clipboard

Connection to SQS does not recover?

Open thehappycoder opened this issue 4 years ago • 5 comments

After an app loses connection with SQS, it's unable to recover it once the Internet connection is back.

I've noticed this when I left my app running on my laptop overnight (with wifi off) and opened it in the morning to find this:

Error   01/03/2021, 22:00:18 /Users/anton/projects/****/tail/node_modules/sqs-consumer/dist/consumer.js:45
    const sqsError = new errors_1.SQSError(message);
                     ^ - {"stack":[null]}
Error   01/03/2021, 22:00:18 SQSError: SQS receive message failed: Inaccessible host: `sqs.ap-southeast-2.amazonaws.com'. This service may not be available in the `ap-southeast-2' region.
    at toSQSError (/Users/anton/projects/****/tail/node_modules/sqs-consumer/dist/consumer.js:45:22)
    at Consumer.receiveMessage (/Users/anton/projects/****/tail/node_modules/sqs-consumer/dist/consumer.js:155:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:94:5) - {"stack":[null]}

This is fine but when the wifi is back on, and I push events to the queue, the app doesn't seem to be consuming anything.

thehappycoder avatar Mar 01 '21 20:03 thehappycoder

Hi @thehappycoder , I have the same problem, did you find a solution to ensure that the connection is retablished ?

spaquis avatar Jun 04 '21 11:06 spaquis

Same problem, any quick resolutions available?

adamr2 avatar Feb 24 '22 18:02 adamr2

Make sure you have an @SqsConsumerEventHandler("queue_name", "error") handler. The default EventEmitter behavior when there isn't an error listener is rather extreme -- the process exits:

If an EventEmitter does not have at least one listener registered for the 'error' event, and an 'error' event is emitted, the error is thrown, a stack trace is printed, and the Node.js process exits. Source: https://nodejs.org/api/events.html#error-events

jyustman avatar Mar 11 '22 23:03 jyustman

The param name is confusing for this decorator, should be queueName.

gaurav1999 avatar Dec 07 '22 13:12 gaurav1999

please see issue #42 -- if the promise doesn't resolve it will deadlock until reboot. there needs to be a TTL that will force reset the loop

JacobJohansen avatar Jan 04 '23 20:01 JacobJohansen