Amazon SNS endpoint disabled in php. But when I log the response, I get the endpoint status as enabled

I am facing an issue where the SNS endpoint gets disconnected when I call the SNS server. I have added logs for debugging. In logs it shows the truth and in Amazon SNS it shows false. Please help me to deal with situations.

Below is the code I am writing to set the endpoint attributes.

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

      

Login response I receive from Amazon SNA 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 a notification

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

      

Publish Journal:

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 posting I check the status of the endpoint using 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 answer, I am getting the endpoint status as true. But I am not receiving any push notifications and Amazon SNS status is showing as false.

Hello,

Wamsi

+3


source to share


1 answer


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'
    )
));

      

What you get both true in the log and actual is false in the AWS SNS app.



Try this to find arn enabled state false or true.

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

      

+1


source







All Articles