未收到 AWS 中 SNS 提供的 headers 列表中的订阅 url?
Not receiving subscription url in the list of headers provided by SNS in AWS?
所以,我正在使用 restifyJS 接收 SNS 通知,我为此创建了一个主题并使用适当的 ARN 订阅了它。我使用了一个 https 端点,当我请求确认时,我得到以下 headers 当我请求确认时。
{
connection: 'upgrade',
'x-real-ip': '*****************My IP address *****************',
'x-forwarded-for': '*************My IP address ************',
host: 'localhost:3000',
'content-length': '1530',
'x-amz-sns-message-type': 'SubscriptionConfirmation',
'x-amz-sns-message-id': '*************************************',
'x-amz-sns-topic-arn': 'arn:aws:sns:ap-south - ************',
'content-type': 'text/plain; charset=UTF-8',
'user-agent': 'Amazon Simple Notification Service Agent',
'accept-encoding': 'gzip,deflate'
}
但我没有收到订阅 URL。
它不在 headers 中...它在请求 body("JSON document")中。
Based on the type specified by the header field x-amz-sns-message-type
, your code should read the JSON document contained in the body of the HTTP request and process the message.
https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html
如前所述,url 在请求 body 中。另请注意,body 是 JSON,但 content-type 设置为 text/plain,这可能会导致某些解析器提供空请求 body。
您可以根据 'x-amz-sns-message-type' header.
的存在,为 restify 提供一个 text/plain 格式器来解析 SNS 消息的 json 内容
所以,我正在使用 restifyJS 接收 SNS 通知,我为此创建了一个主题并使用适当的 ARN 订阅了它。我使用了一个 https 端点,当我请求确认时,我得到以下 headers 当我请求确认时。
{
connection: 'upgrade',
'x-real-ip': '*****************My IP address *****************',
'x-forwarded-for': '*************My IP address ************',
host: 'localhost:3000',
'content-length': '1530',
'x-amz-sns-message-type': 'SubscriptionConfirmation',
'x-amz-sns-message-id': '*************************************',
'x-amz-sns-topic-arn': 'arn:aws:sns:ap-south - ************',
'content-type': 'text/plain; charset=UTF-8',
'user-agent': 'Amazon Simple Notification Service Agent',
'accept-encoding': 'gzip,deflate'
}
但我没有收到订阅 URL。
它不在 headers 中...它在请求 body("JSON document")中。
Based on the type specified by the header field
x-amz-sns-message-type
, your code should read the JSON document contained in the body of the HTTP request and process the message.https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html
如前所述,url 在请求 body 中。另请注意,body 是 JSON,但 content-type 设置为 text/plain,这可能会导致某些解析器提供空请求 body。 您可以根据 'x-amz-sns-message-type' header.
的存在,为 restify 提供一个 text/plain 格式器来解析 SNS 消息的 json 内容