简体   繁体   English

AWS SNS 停止传送消息

[英]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.我尝试从 AWS SNS API 到 JAVA 发送 SMS,它工作了两天,然后突然停止传递消息,但是来自 API 的响应是 200 ok,具有正确的消息 ID,但没有传递消息。 I am trying to post the request through postman to get more clarity of the issue but cannot find any collection or request signature.我试图通过 postman 发布请求以更清楚地了解问题,但找不到任何集合或请求签名。

` `

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.我正在使用上面的代码,它给出了 200 O 作为响应以及请求和消息 ID,但消息没有传递。

You can refer these examples from AWS to form the request.您可以从 AWS 参考这些示例来形成请求。

Alternative, you can enable verbose logging in your java code to see request.或者,您可以在 java 代码中启用详细日志记录以查看请求。 refer this or this document from AWS to enable verbose logging.从 AWS 参考文档或文档以启用详细日志记录。

or要么

execute aws cli to send sms from aws sns with --debug true option, which will also print the request on command line.执行 aws cli 以使用--debug true选项从 aws sns 发送短信,这也会在命令行上打印请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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