Sending SNS notifications on Amazon with Laravel

Asked

Viewed 191 times

1

When running ->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 performing various tests and debugging the variable values, I print the variable that stores the client’s codarn ($target) and it’s OK. I even copied the value of the variable and then put it directly in the method to which I implement the upload and worked normally. Only when I pass the value as 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 Requestid is purposeful and to keep confidential the value of the client’s codarn.

1 answer

0

The whole time I used the AWS notification service, I always selected the region us-West-2. Even now I have several applications using this region.

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

  1. The region does not accept new applications and was or was experiencing instability at the time OR
  2. The region only accepts use in SAND_BOX mode.

Remembering that sending occurred normally when done manually and or when the Endpoint ARN value was inserted directly into the code.

I am using the Lumen/Laravel 5.2, the SDK in the latest version until that date and the solution of the problem came when created another application in another region.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.