Sending SNS notifications to Amazon with Laravel

1

When executing the method - > sns- > publish I have the following error:

Error executing "Publish" on "https://sns.us-west-2.amazonaws.com"; AWS HTTP error: Client error: 'POST https://sns.us-west-2.amazonaws.com' resulted in a '400 Bad Request' response:

<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
    <Error>
        <Type>Sender</Type>
        <Code>InvalidPara (truncated...)
 InvalidParameter (client): Invalid parameter: TargetArn Reason: ARN specifies an invalid endpointId: UUID must be encoded in exactly 36 characters. - 
            <ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
                <Error>
                    <Type>Sender</Type>
                    <Code>InvalidParameter</Code>
                    <Message>Invalid parameter: TargetArn Reason: ARN specifies an invalid endpointId: UUID must be encoded in exactly 36 characters.</Message>
                </Error>
                <RequestId>a634effa-XXXX-XXXX-XXXX-bfeb15b8XXXX</RequestId>
            </ErrorResponse>

By doing several tests and debugging the variable values, I print the variable that stores the client's code ($ target) and it is OK. I copied the value of the variable and then put it directly into the method to which it was uploading and worked normally . Only when I pass the value as a parameter does the error occur. This is my implemented method:

public function publishMessage($target, $message) {
        try {            
            $result = $this->sns->publish([
                'MessageStructure' => 'json',
                'Message' => $message,
                'TargetArn' => $target,
            ]);
        } catch (\Aws\Sns\Exception\SnsException $exc) {
            echo $exc->getMessage();
            return false;
        }
        return $result;
    }

PS: the XXX in the RequestId is intentional and to keep the codarn value of the client confidential.

    
asked by anonymous 26.07.2016 / 18:27

1 answer

0

Throughout the time I've used the AWS notification service, I've always selected the us-west-2 region. I currently even have multiple applications using this region.

This time when creating the application appeared this problem even a bit bizarre. Without any plausible explanation or that could clarify what happened, I had two alternatives:

  • The region no longer accepts new applications and either was currently unstable OR
  • The region only accepts use in SAND_BOX mode.
  • Remembering that the sending occurred normally when done manually and or when the value of the Direct RNA Endpoint was entered in the code.

    I'm using lumen / laravel 5.2, the SDK in the most recent version up to that date and the problem solved when I created another application in another region .

        
    27.07.2016 / 23:13