简体   繁体   中英

AWS SNS stopped delivering messages

I tried sending SMS from AWS SNS API through JAVA which worked for two days then suddenly stopped delivering messages but the response from API is 200 ok with a proper message ID without delivering messages. I am trying to post the request through postman to get more clarity of the issue but cannot find any collection or request signature.

`

public class SNS {
    public static void sendSMS(String phoneNumber,String message)
    {
        
        
        BasicAWSCredentials basicCred = new BasicAWSCredentials("XXXXXXXXXXX", "XXXXXXXXXXXXX");

        AmazonSNSClient snsClient = (AmazonSNSClient) AmazonSNSClientBuilder.standard()
                .withClientConfiguration(
                        new ClientConfiguration()
                        .withMaxErrorRetry(0)
                        .withConnectionTimeout(1000))
                .withCredentials(new AWSStaticCredentialsProvider(basicCred))
                .withRegion("us-east-1")
                .build();

        Map<String, MessageAttributeValue> smsAttributes = 
                new HashMap<String, MessageAttributeValue>();

        smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue()
                .withStringValue("Sender") //The sender ID shown on the device.
                .withDataType("String"));      
        smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue()
                .withStringValue("Transactional") //Sets the type to Transactional.
                .withDataType("String"));       

        sendSMSMessage(snsClient, message, phoneNumber, smsAttributes);
    }

    public static void sendSMSMessage(AmazonSNSClient snsClient, String message, 
            String phoneNumber, Map<String, MessageAttributeValue> smsAttributes) 
    {
        PublishResult result = snsClient.publish(new PublishRequest()
                .withMessage(message)
                .withPhoneNumber(phoneNumber)
                .withMessageAttributes(smsAttributes));
    }
    
    public static void main(String[] args) {
        sendSMS("+91XXXXXXXXXX", "Hi This is Test message from SNS");
    }
}`

I am using the above code which is giving 200 O in response along with request and message Id but the message is not delivered.

You can refer these examples from AWS to form the request.

Alternative, you can enable verbose logging in your java code to see request. refer this or this document from AWS to enable verbose logging.

or

execute aws cli to send sms from aws sns with --debug true option, which will also print the request on command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM