I 'm invocate sqs.receiveMessage(receiveParams, function(err, data){}) inside an infinite loop. But it didn't get triggered at all.
var receiveParams = { QueueUrl: queueUrl, VisibilityTimeout: 40 }; while (true) { console.log("before"); setTimeout(function() { sqs.receiveMessage(receiveParams, function(err,data){ console.log("Calling"); if (err) { console.log(err); } else { console.log(data); if (data.Messages != null) { console.log("Executing my fuction"); myFunction(); } } }); }, 10000); console.log("after"); } If I execute sqs.receiveMessage() outside the loop, it works fine. I don't know why it never gets invocated in the loop. I'm guessing there is something wrong with my timeout settings. Because my loop will log "before" and "after" without time delay. Any Help?