I tried sending sms with amazon sns and I got
SMS message published to phone number +23481XXXXXXX successfully.
Message "ID": *********************
But the message status show "fail".
Please is there any other thing I have to do after verifying my account before I start sending sms?
You might also want to check if the region you're using supports sms and if the country you're trying to send has support.
https://docs.aws.amazon.com/sns/latest/dg/sns-supported-regions-countries.html
Not sure if this is just SNS related or if you're trying to send sms after an account was created in cognito, might want to check region support for that too
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-email-phone-verification.html
You can activate Delivery status logging to obtain a more-detailed log for SMS messages.
From Viewing Amazon CloudWatch metrics and logs for SMS deliveries - Amazon Simple Notification Service:
Activate Delivery status logging
Send a message
View the results in Amazon CloudWatch Logs
Here is an example log entry:
{
"notification": {
"messageId": "1077257a-92f3-5ca3-bc97-6a915b310625",
"timestamp": "2016-06-28 00:40:34.559"
},
"delivery": {
"mnc": 0,
"destination": "+1XXX5550100",
"priceInUSD": 0.00645,
"smsType": "Transactional",
"mcc": 0,
"providerResponse": "Unknown error attempting to reach phone",
"dwellTimeMs": 1420,
"dwellTimeMsUntilDeviceAck": 1692
},
"status": "FAILURE"
}
Related
I created a SNS subscription and started receiving bunch of emails
I'm interested in receiving only following emails:
All emails with pipeline name and status weather failed or succeeded in message body
{"account":"","detailType":"CodePipeline Pipeline Execution State Change","region":"ap-south-1","source":"aws.codepipeline","time":"","notificationRuleArn":"arn:aws:codestar-notifications:ap-south-1:notificationrule/3a1a2bf7acf27ba4dba4b9bbab0ac14550994ec6","detail":{"pipeline":"demo","execution-id":"2df769bc-37b6-4853-942a-7e2fc1c0b66d","state":"SUCCEEDED","version":5.0},"resources":["arn:aws:codepipeline:ap-south-1"],"additionalAttributes":{}}
Tried adding below in subscription filter policy for status :
{
"status": [
"failed",
"succeeded"
]
}
but not even getting notification after this?
I am trying to send SMS through AWS SNS. Message body includes a URL to the webpage for user invite.
Messages work for Australia but when I send similar message to New Zealand, it fails.
If I remove URL from message body, SMS is sent otherwise it fails.
Here is the AWS cloudwatch log
{
"notification": {
"messageId": "..........",
"timestamp": "2021-10-25 14:18:44.002"
},
"delivery": {
"numberOfMessageParts": 1,
"destination": "+64........",
"priceInUSD": 0.12146,
"smsType": "Transactional",
"providerResponse": "Phone is currently unreachable/unavailable",
"dwellTimeMs": 1011,
"dwellTimeMsUntilDeviceAck": 3192
},
"status": "FAILURE"
}
Looking through AWS forums it says that one one the possibilities for this response can be invalid message body.
Interestingly if I add https://google.com in message body, SMS is sent.
I encountered the same issue. All of a sudden all of our SMS failed to send (our texts include a link). I tried sending various links all failed to send; however, www.google
I'm trying to send sms confirmation messages with Amazon SNS to the phones of users who sign up for an account using cognito and verify their phone numbers. My cognito user pool is located at us-east-2 and I recently got my spend limit increased to $50 for both us-east-1 and us-east-2. I tested sending sms messages through the sns console to my phone and that works perfectly. However, I don't get the sms messages when trying to verify users on cognito. When checking the sns console, it looks like the only successful messages that are being sent to my phone were my manual sent messages from the console and everything else has failed. Any help would be greatly appreciated.
I have found that the error comes for my specific phone number as a sprint carrier and get the following log failed response:
{
"notification": {
"messageId": "5dab56f3-2dd3-5a6d-b96e-0e96904d334b",
"timestamp": "2020-12-29 23:27:26.712"
},
"delivery": {
"phoneCarrier": "SPRINT Spectrum L.P.",
"mnc": 880,
"numberOfMessageParts": 1,
"destination": "+1******3252",
"priceInUSD": 0.00645,
"smsType": "Transactional",
"mcc": 311,
"providerResponse": "Blocked as spam by phone carrier",
"dwellTimeMs": 202,
"dwellTimeMsUntilDeviceAck": 1254
},
"status": "FAILURE"
}
However, I tested with an AT&T phone and TMobile phone and they get the messages delivered successfully with the following log response:
{
"notification": {
"messageId": "3106a00c-40de-53ce-9f40-f869fc025013",
"timestamp": "2020-12-29 23:24:12.183"
},
"delivery": {
"phoneCarrier": "T-mobile USA Inc.",
"mnc": 800,
"numberOfMessageParts": 1,
"destination": "+1******1131",
"priceInUSD": 0.00645,
"smsType": "Transactional",
"mcc": 310,
"providerResponse": "Message has been accepted by phone",
"dwellTimeMs": 238,
"dwellTimeMsUntilDeviceAck": 601251
},
"status": "SUCCESS"
}
This error is really weird to me as there should be no reason why SPRINT blocks my phone from getting sms messages from aws sns on cognito only but other phone services allow getting messages. I also still am able to get messages from the SNS console but only cognito fails to send with the carrier blocking it. Any help would be greatly appreciated!
Since you are able to receive SNS SMS from AT&T and T-Mobile phone carrier, I would strongly suggest that you contact AWS Premium Support to help you identify why SMS sent to SPRINT Spectrum L.P. are not being delivered.
I using sns of aws to send sms, when I log cloudwatch i see:
{
"notification": {
"messageId": "ac8d8d02-491d-58bf-ace8-xxxxxx",
"timestamp": "2021-01-01 00:03:54.576"
},
"delivery": {
"phoneCarrier": "Viettel",
"mnc": 4,
"numberOfMessageParts": 1,
"destination": "+843293xxxxx",
"priceInUSD": 0.0525,
"smsType": "Transactional",
"mcc": 452,
"providerResponse": "Message has been accepted by phone carrier",
"dwellTimeMs": 361,
"dwellTimeMsUntilDeviceAck": 2604
},
"status": "SUCCESS"
}
But in my phone, I don't get any message, How I fix it?
For several countries, senders are required to use a pre-registered alphabetic sender ID.
To request a sender ID from AWS Support, file a support request. Some countries require senders to meet specific requirements or abide by certain restrictions in order to obtain approval.
In these cases, AWS Support might contact you for additional information after you submit your sender ID request.
For further information about this, you can read this docs.
The documentation for AWS SNS and SQS have sections about message attributes. But there is no explanation how to have SQS message attributes when that queue is subscribed to a SNS topic.
Is there a way to configure AWS SNS to add particular message attributes to the SQS messages send via the subscription?
From aws documentation:
To use message attributes with Amazon SQS endpoints, you must set the subscription attribute, Raw Message Delivery, to True. For more information about raw message delivery, see Appendix: Large Payload and Raw Message Delivery.
https://docs.aws.amazon.com/sns/latest/dg/SNSMessageAttributes.html
https://docs.aws.amazon.com/sns/latest/dg/large-payload-raw-message.html
Added an example from real-life project. Hopefully it helps to clarify things.
The message published to the sns topic is following:
aws sns publish --topic-arn arn:aws:sns:us-west-2:xxx:pollution-event --message '{"operatorId":3375001,"eventTypeId":1,"eventLevelId":1,"validFrom":"2018-03-10T09:00:00Z","validTo":"2018-03-11T09:00:00Z"}' --message-attributes '{"Type" : { "DataType":"String", "StringValue":"Orchestration.Services.Model.Pollution.PollutionMessage"}}'
Enable Raw Delivery is false (default). The message received by sqs contains only content, there are no attributes
{
"Type": "Notification",
"MessageId": "78d5bc6f-142c-5060-a75c-ef29b774ec66",
"TopicArn": "arn:aws:sns:eu-west-2:xxx:pollution-event",
"Message": "{\"validFrom\": \"2018-03-10T09:00:00Z\",\"validTo\": \"2018-03-11T09:00:00Z\",\"eventLevelId\": 1,\"eventTypeId\": 1,\"operatorId\": 3375001}",
"Timestamp": "2018-04-17T11:33:44.770Z",
"SignatureVersion": "1",
"Signature": "xxx==",
"SigningCertURL": "https://sns.eu-west-2.amazonaws.com/SimpleNotificationService-xxx.pem",
"UnsubscribeURL": "https://sns.eu-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-2:xxx",
"MessageAttributes": {
"Type": {
"Type": "String",
"Value": "Orchestration.Services.Model.Pollution.PollutionMessage"
},
"AWS.SNS.MOBILE.MPNS.Type": {
"Type": "String",
"Value": "token"
},
"AWS.SNS.MOBILE.MPNS.NotificationClass": {
"Type": "String",
"Value": "realtime"
},
"AWS.SNS.MOBILE.WNS.Type": {
"Type": "String",
"Value": "wns/badge"
}
}
}
Enable Raw delivery is true. The message contains the message attributes and proper content
Note: See other answer for better response, using Raw Message Delivery
While the Using Amazon SNS Message Attributes documentation sending Amazon SNS message attributes to Amazon SQS, it appears that the attributes are sent in the body of the message rather than being attached as message attributes on the resulting Amazon SQS messages.
For example, I did the following:
Created an Amazon SNS topic
Created an Amazon SQS queue and subscribed it to the SNS topic
Published a message to SNS
I published via the AWS Command-Line Interface (CLI):
aws sns publish --topic-arn arn:aws:sns:ap-southeast-2:123456789012:foo --message msg --subject subj --message-attributes '{"somename" : { "DataType":"String", "StringValue":"somevalue"}}'
(I got syntax help from map datatype in aws cli)
The resulting message in SQS showed the attributes as part of the message:
{
"Type" : "Notification",
"MessageId" : "53e3adad-723a-5eae-a7b7-fc0468ec2d37",
"TopicArn" : "arn:aws:sns:ap-southeast-2:123456789012:foo",
"Subject" : "subj",
"Message" : "msg",
"Timestamp" : "2017-05-29T12:48:22.186Z",
...
"MessageAttributes" : {
"somename" : {"Type":"String","Value":"somevalue"}
}
}
It would be much nicer if these attributes were attached to the SQS message as official SQS attributes. Alas, it seems this is not the case.
Enabled Raw message delivery type while adding SQS subscription for the topic inside SNS
If you are here because you have a SQS queue that is subscribed to an SNS topic, you checked that your subscription has set the Raw Message Delivery to True but you still cannot read an attribute on your SQS message:
Make sure that your SQS client is not filtering out message attributes.
The code below will only include myAttribute when receiving messages from the SQS queue:
SQS.receiveMessage({
QueueUrl: queueUrl,
VisibilityTimeout: 20,
WaitTimeSeconds: 10,
MessageAttributeNames: [
"myAttribute"
],
},...
If you want to read the value of some attribute other than myAttribute you will have to specify it (white list) or replace "myAttribute" with "All" to include all SQS attributes.
SQS.receiveMessage({
MessageAttributeNames: [
"myAttribute", "myOtherAttribute"
],
},...
Reference: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html