Showing posts with label amazon web services. Show all posts
Showing posts with label amazon web services. Show all posts

November 13, 2019

AWS SDK cURL error 28 Connection timed out

If when using Amazon / AWS PHP SDK (for e.g. AWS SES) you're getting this error
cURL error 28: Connection timed out after 1001 milliseconds
make sure you got the credentials right; pay attention to the key nesting (i.e. key and secret go under credentials)
$client = SesClient::factory(array(
  'version'   => 'latest',
  'region'    => 'eu-north-1',
  'credentials' => array(
    'key'       => AWS_KEY,
    'secret'    => AWS_SECRET,
  ),
));
This may not be a network connection problem after all. more info

January 8, 2017

Amazon Mobile Analytics: com.amazon.coral.service SerializationException not an expected Json type

When trying to submit a custom event having attributes and metrics to Amazon Mobile Analytics, I got the following error:

object(stdClass) {
 __type => 'com.amazon.coral.service#SerializationException'
 Message => 'class java.lang.String is not an expected Json type'
}

The problem was the data type of the attributes and metrics I was trying to send. AWS REST API has strict requirements for those. The solution was to convert attribute values to strings (strval()) and metrics to integers (intval()).

January 3, 2017

AWS mobile analytics Client context is malformed or missing

com.amazonaws.mobileanalytics.exceptions#BadRequestException Client context is malformed or missing

First, remove all spaces, tabs, or end of line characters.

In my case it was something else though - AWS Mobile Analytics doesn't seem to accept the empty object keys.


Just remove it or add some values into it.

AWS responds "The request signature we calculated does not match the signature you provided"

The first thing to do is check if your string-to-sign matches the one AWS expects.

If it does, but you're still getting that error, try regenerating your Secret access key until you get one without any special characters. No slashes, no plus signs, just letters and numbers. In some cases (such as mine) that helps.

Go to AWS IAM Users Management Console, click your user, go to the Security Credentials tab, scroll down to Access Keys, delete the ones you don't need (the limit per IAM user is 2) and finally click Create Access Key. Repeat until you get a clean, alphanumeric one

aws signature v4 troubleshooting string to sign

If you're trying to use Amazon AWS Signature Version 4 class and it throws you a 403 Forbidden error, you need to troubleshoot your request. As suggested in the official troubleshooting guide, you'll have to compare your string-to-sign with the one AWS expects. The latter will be present in their response body.

To get the former, find a SignatureV4.php file on your system and var_dump() the $toSign variable here:
https://github.com/aws/aws-sdk-php/blob/master/src/Signature/SignatureV4.php#L50

Compare your string-to-sign with Amazons. If they match, but you're still getting the 403 Forbidden error, try regenerating your Secret access key.

403 forbidden mobileanalytics.us-east-1.amazonaws.com

The API endpoint for AWS Mobile Analytics shown in the documentation, as of now, is https://mobileanalytics.us-east-1.amazonaws.com/2014-06-05/events. If you've changed that 2014 date part in it to something else, you're likely to get a 403 forbidden error. The actual endpoint url has to have that fixed date since it represents the API version, not the date of the event you're trying to submit.


https://forums.aws.amazon.com/message.jspa?messageID=566419