Aws-sdk-php: AWS HTTP error: count() PHP Version 7.2

Created on 25 Apr 2018  路  6Comments  路  Source: aws/aws-sdk-php

I updated the PHP Version and the lib stop working, this is happening in:

S3

Error executing "PutObject" on "https://s3.amazonaws.com/....; AWS HTTP error: count(): Parameter must be an array or an object that implements Countable
/var/www/html/Project/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php (192)

SES

Err: Error executing "SendEmail" on "https://email.us-east-1.amazonaws.com"; AWS HTTP error: count(): Parameter must be an array or an object that implements Countable, /var/www/html/Project/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php (192)

Most helpful comment

@howardlopez @kstich

Hi, I resolved the problem.

I forced the version off guzzle for 6.3. Actually the problem is with the guzzle and not with the AWS.

You need to update the version for "guzzlehttp/guzzle": "6.3", to for this is work fine.

All 6 comments

Track code

2018-04-25 14:50:39, PosixPID(7578): Err: Error executing "SendEmail" on "https://email.us-east-1.amazonaws.com"; AWS HTTP error: count(): Parameter must be an array or an object that implements Countable, /var/www/html/WE/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php (192),
2) Project/init.php(1886): Aws\AwsClient->__call('sendEmail', Array)
3) Project/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(78): Aws\AwsClient->execute(Object(Aws\Command))
4) Project/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(59): GuzzleHttp\Promise\Promise->wait()
5) Project/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
6) Project/vendor/guzzlehttp/promises/src/Promise.php(221): GuzzleHttp\Promise\Promise->invokeWaitList()
7) Project/vendor/guzzlehttp/promises/src/Promise.php(265): GuzzleHttp\Promise\Promise->waitIfPending()
8) Project/vendor/guzzlehttp/promises/src/Promise.php(221): GuzzleHttp\Promise\Promise->invokeWaitList()
9) Project/vendor/guzzlehttp/promises/src/Promise.php(262): GuzzleHttp\Promise\Promise->waitIfPending()
10) Project/vendor/guzzlehttp/promises/src/Promise.php(230): GuzzleHttp\Promise\TaskQueue->run()
11) Project/vendor/guzzlehttp/promises/src/TaskQueue.php(61): GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise{closure}()
12) Project/vendor/guzzlehttp/promises/src/RejectedPromise.php(40): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}(Array)
13) Project/vendor/guzzlehttp/promises/src/Promise.php(172): GuzzleHttp\Promise\Promise::callHandler(2, Array, Array)
14) Project/vendor/guzzlehttp/promises/src/Promise.php(201): Aws\WrappedHttpHandler->Aws{closure}(Array)
15) Project/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(101): Aws\WrappedHttpHandler->parseError(Array, Object(GuzzleHttp\Psr7\Request), Object(Aws\Command), Array)

Can you please post a code sample for what is generating the SendEmail issue you posed the stack trace for?

Yes, this is the code.

$sesClient = new \Aws\Ses\SesClient([
    "version" => "latest",
    "region" => "us-east-1",
    "credentials" => [
        "key"       => $config->email_user_aws,
        "secret"    => $config->email_pass_aws
    ]
]);
try {
    $send = $sesClient->sendEmail([
        "Source" => utf8_encode("{$config->email_from_name} <{$config->email_from}>"),
        "Destination" => [
            "ToAddresses" => $to,
            "CcAddresses" => $cc,
            "BccAddresses" => $cco,
        ],
        "Message" => [
            "Subject" => [
                "Data" => $assunto,
                "Charset" => "UTF-8"
            ],
            "Body" => [
                "Html" => [
                    "Data" => $msg,
                    "Charset" => "UTF-8"
                ]
            ]
        ],
        "ReplyToAddresses" => [
            $config->email_no_reply
        ]
    ]);

    if(is_array($send->toArray()) && isset($send->toArray()['MessageId'])){
        return true;
    }

}catch (\Exception $e){
    throw new Exception($e);
}

@dfrnks Would you mind also putting the code for the PutObject call and the stack trace you got from it?

@howardlopez @kstich

Hi, I resolved the problem.

I forced the version off guzzle for 6.3. Actually the problem is with the guzzle and not with the AWS.

You need to update the version for "guzzlehttp/guzzle": "6.3", to for this is work fine.

Well, I fixed this problem recently by simply updating the aws.phar file using below.

ie. I am using the latest aws.phar, which resolves guzzle issue.

curl -L -o /path/to/my/library/aws.phar https://github.com/aws/aws-sdk-php/releases/download/3.100.4/aws.phar

Was this page helpful?
0 / 5 - 0 ratings