繁体   English   中英

AWS SNS 停止传送消息

[英]AWS SNS stopped delivering messages

我尝试从 AWS SNS API 到 JAVA 发送 SMS,它工作了两天,然后突然停止传递消息,但是来自 API 的响应是 200 ok,具有正确的消息 ID,但没有传递消息。 我试图通过 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");
    }
}`

我正在使用上面的代码,它给出了 200 O 作为响应以及请求和消息 ID,但消息没有传递。

您可以从 AWS 参考这些示例来形成请求。

或者,您可以在 java 代码中启用详细日志记录以查看请求。 从 AWS 参考文档或文档以启用详细日志记录。

要么

执行 aws cli 以使用--debug true选项从 aws sns 发送短信,这也会在命令行上打印请求。

暂无
暂无

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

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