Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Issues with AWS SDK #33

Closed
martinssipenko opened this issue Oct 16, 2018 · 2 comments
Closed

Issues with AWS SDK #33

martinssipenko opened this issue Oct 16, 2018 · 2 comments

Comments

@martinssipenko
Copy link

Hi,

I'm trying to use this adapter together with AWS SDK version 3, but I'm running into issue that I can't figure out.

<?php

use Aws\Result;
use Aws\Sdk;
use GuzzleHttp\HandlerStack;
use React\EventLoop\Factory;
use WyriHaximus\React\GuzzlePsr7\HttpClientAdapter;

require 'vendor/autoload.php';

$loop = Factory::create();
$sdk = new Sdk([
    'region'       => 'us-east-1',
    'version'      => 'latest',
    'http_handler' => HandlerStack::create(new HttpClientAdapter($loop)),
]);

$sts = $sdk->createSts();

$sts->getCallerIdentityAsync([
])->then(function ($response) {
    var_export((string) $response['Account']);
}, function ($fail) {
    var_export((string) $fail);
});

$loop->run();

When I put this code in a php file and run it from console I get no output. I expect that my AWS account id would be displayed. (I have AWS config configured in my home directory).

<?php

use Aws\Result;
use Aws\Sdk;
use GuzzleHttp\HandlerStack;
use React\EventLoop\Factory;
use WyriHaximus\React\GuzzlePsr7\HttpClientAdapter;

require 'vendor/autoload.php';

$loop = Factory::create();

$handler = new \WyriHaximus\React\GuzzlePsr7\HttpClientAdapter($loop);
$stack   = \GuzzleHttp\HandlerStack::create($handler);

$client  = new \GuzzleHttp\Client([
    'handler' => $stack,
]);

$sdk = new Sdk([
    'region'       => 'us-east-1',
    'version'      => 'latest',
    'http_handler' => HandlerStack::create(new HttpClientAdapter($loop)),
]);

$sts = $sdk->createSts();

$client->requestAsync('GET', 'https://example.com/');

$sts->getCallerIdentityAsync([
])->then(function ($response) {
    var_export((string) $response['Account']);
}, function ($fail) {
    var_export((string) $fail);
});


$loop->run();

However, if I use the above code, everything works as expected. Note that I've added the $client->requestAsync('GET', 'https://example.com/'); call which makes the difference. If I comment that function call out I don't get any response again.

I'm using:

        "aws/aws-sdk-php": "^3.69",
        "wyrihaximus/react-guzzle-psr7": "^2.1"

and I've also tested this with packages down to versions:

        "guzzlehttp/guzzle": "6.0.1",
        "aws/aws-sdk-php": "3.17.4",
        "wyrihaximus/react-guzzle-psr7": "2.0.1"
@WyriHaximus
Copy link
Owner

Hey this might have something to do with guzzle's promise queue. Could you try composer update --prefer-lowest and see if that works? (Just to see if that works, revert to current versions after. (Something might have changed in Guzzle lately.)) While I dive into the adapter.

@WyriHaximus
Copy link
Owner

Just created #34 to solve this. Could you test it out for me using composer require wyrihaximus/react-guzzle-psr7:dev-keep-ticking-the-queue-untill-it-is-empty?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants