Reputation: 73
I have a function that sends off a text message when run:
def txtUserValidationCode(countryCode, phoneNum, message):
sns = boto3.client('sns')
try:
logger.info("Trying to send text")
sns.publish(
PhoneNumber="+" + countryCode + phoneNum,
Message=message
)
except:
logger.info("Text message failed")
else:
logger.info("Text message successful")
Sometimes it works, sometimes it times out, even when the input parameters are exactly the same. Is there a throttle on how many texts you can send with boto3 SNS? I just tried to hard code the phone number and message in to test whether it was my inputs throwing the publish method off, however it still did not work.
Even more confusing is the fact that it is not throwing an error, just a timeout.
More confusing is the fact when I copy and paste the same code into another function, it works fine.
Does anyone have an explanation for this? I read through SNS docs and did not find anything that could explain this. I am thinking maybe I need to request a quota increase?
btw: lambda has admin permissions
UPDATE Function just succeeded, changed nothing, just tested it again after 15 minutes. Would really like to know what accounts for the timeout. Should I increase the timeout for my lambda? I also changed the default type of text message to transactional as I see they get higher priority? Perhaps this is why? Any answers help
Upvotes: 1
Views: 557
Reputation: 73
I went to the SNS console and changed my default message to transactional, which gives it higher precedence in AWS queue. So far, that has worked without fail.
Upvotes: 1
Reputation: 269330
It sounds like you have an AWS Lambda function that is associated with multiple subnets, and some of those subnets are public and some are private.
The preference would be to use an AWS Lambda function that is not associated with a VPC. This will provide direct access to the Internet and, therefore, to Amazon SNS.
However, if the AWS Lambda function is associated with a VPC, ensure that:
Upvotes: 1