简体   繁体   中英

Amazon SNS endpoint getting disabled in php But when I log the response I am getting endpoint status as enabled

I am facing issue with SNS endpoint getting disabled when I make a call to SNS server. For debugging I added logs. In logs it is showing true and in Amazon SNS it is showing false. Please help me how to handle the situations

Following is the code I am writing for setting the endpoint Atrributes.

$enable_end_point = $client->setEndpointAttributes(array(
    'Endpoenter code hereintArn' => $pushlist[$i]['aws'],
    'Attributes' => array(
    'Enabled' => 'true'
    )`enter code here`
));

Log response I am getting from Amazon SNS server

data: get paramsGuzzle\Service\Resource\Model Object(
    [structure:protected] => 
    [data:protected] => Array
    (
        [Attributes] => Array(
            [Enabled] => true
            [Token] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        )

        [ResponseMetadata] => Array(
            [RequestId] => 1ef66366-6dc3-549a-8d38-2d4a5axxxxx
        )

    )
)

Publishing the notification

$result = $client->publish(array(
    'TargetArn' => $pushlist[$i]['aws'],
    'Message' => $msg_json,
    'Subject' => 'New xxxxx',
    'MessageStructure' => 'json',
));

Publish log:

data: publish resultGuzzle\Service\Resource\Model Object
(
    [structure:protected] => 
    [data:protected] => Array
    (
        [MessageId] => 5bbeb85f-75e7-5967-a55a-f673424xxxxx
        [ResponseMetadata] => Array
        (
            [RequestId] => 5c7f3df2-ff65-5bb5-a74a-73dec8cxxxxx
        )

    )
)

After publish I am checking the endpoint status through logs

data: get params after publishGuzzle\Service\Resource\Model Object
(
    [structure:protected] => 
    [data:protected] => Array
    (
        [Attributes] => Array
        (
            [Enabled] => true
            [Token] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        )
        [ResponseMetadata] => Array
        (
            [RequestId] => f3bdbb0d-9666-5b38-84a0-f521a1cxxxxx
        )

    )
)

In the above response I am getting endpoint status as true. But I am not getting any push notifications and on Amazon SNS status is showing as false.

Regards,

Vamsi

I think you were sending attributes with Enabled as true,

$enable_end_point = $client->setEndpointAttributes(array(
    'Endpoenter code hereintArn' => $pushlist[$i]['aws'],
    'Attributes' => array(
    'Enabled' => 'true'
    )
));

That's what you are getting as true in log and the actual is false in AWS SNS Application.

Please try this one to find the arn enabled state is false or true.

$endpointAtt = $sns->getEndpointAttributes($arn_arr);
Log::info($endpointAtt['Attributes']);
if($endpointAtt != 'failed' && $endpointAtt['Attributes']['Enabled'] != 'false') {
   // Code here
}

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