【发布时间】:2020-01-11 00:25:27
【问题描述】:
我在使用 Amazon AWS SNS 时遇到了一个奇怪的问题:使用 aws-php-sdk (3.112.7) 创建订阅和主题时,总是存在“幽灵”或“不可见”订阅。
如您所见,此订阅存在于“订阅”标签中。但是,当我点击主题链接(此处为 cav_56826)时,我看不到任何订阅。
你们是否已经遇到过类似的问题?怎么会这样?
这是我的简化代码:
try
{
$arn = "arn:aws:sns:eu-west-1:XXXXXXXXXXXXXXXXX:app/APNS_VOIP_SANDBOX/ios_cav";
$topics = array("allUsers", "cav_56826");
$topicsToSubcribe = array();
foreach ($topics as $topic)
{
$res = $this->snsClient->createTopic(['Name' => $topic]);
if ($res->get('@metadata')['statusCode'] == 200)
{
array_push($topicsToSubcribe, $res->get('TopicArn'));
}
else
{
throw new Exception("An error occured during Amazon SNS createTopic", $res->get('@metadata')['statusCode']);
}
}
$SNSEndPointData = $this->snsClient->createPlatformEndpoint([
'PlatformApplicationArn' => $arn,
'Token' => $token
]);
foreach ($topicsToSubcribe as $topic)
{
$this->snsClient->subscribe([
'Protocol' => "application",
'Endpoint' => $SNSEndPointData->get('EndpointArn'),
'TopicArn' => $topic
]);
}
}
catch (\Exception $e)
{
// Logs some errors
}
【问题讨论】:
-
另外,当删除一个主题时,重新创建它并进行订阅,似乎都没有添加。但是 SNS 给我发了 200 没有任何错误
-
能否提供您正在使用的
aws-php-sdk的版本,谢谢。 -
3.112.7 ! :)
-
好像有一种缓存系统,真的很奇怪
-
缓存什么?在此问题发生之前您是否创建了一些东西?
标签: amazon-web-services push-notification amazon-sns aws-php-sdk