Retrying is not working on Guzzle 7
hareku opened this issue ยท 9 comments
- Algolia Client Version: 2.7.0
- Language Version: PHP 7.4
Description
Guzzle 7 has breaking changes at the structure of exceptions.
https://github.com/guzzle/guzzle/tree/7.0/src/Exception
Guzzle6HttpClient
catches GuzzleHttp\Exception\RequestException
, but Guzzle 7 throws GuzzleHttp\Exception\ConnectException
if timeout occured.
https://github.com/algolia/algoliasearch-client-php/blob/2.7.0/src/Http/Guzzle6HttpClient.php#L28
Steps To Reproduce
@hareku is Guzzle 7 even supported?
Judging by the Guzzle6HttpClient
name I conclude it's tailored to Guzzle 6.
Even though the Travis tests matrix has Guzzle 7 as one of its dimentions, it seems that only Guzzle 6 and older versions are being used inside (UPD: see my next comment).Algolia::getHttpClient()
algoliasearch-client-php/.travis.yml
Lines 65 to 68 in 0342b0b
algoliasearch-client-php/src/Algolia.php
Lines 98 to 104 in 0342b0b
I guess the best way forward would be to submit a PR:
- introducing
Guzzle7HttpClient
next to the existingGuzzle6HttpClient
adapter - extending
Algolia::getHttpClient()
to instantiate it automatically when possible
Even though the Travis tests matrix has Guzzle 7 as one of its dimentions, it seems that only Guzzle 6 and older versions are being used insideAlgolia::getHttpClient()
:
It seems it is indeed a bug. Either Guzzle6HttpClient
should be fine working with Guzzle 7, or Algolia::getHttpClient()
should not use Guzzle6HttpClient
when Guzzle 7 is installed.
This problem would not exist if Guzzle6HttpClient
was a different Composer package that would require Guzzle v6 explicitly.
Example composer.json:
{
"name": "algolia/algoliasearch-client-php-guzzle6-adapter",
"require": {
"algolia/algoliasearch-client-php": "2.*",
"guzzlehttp/guzzle": "6.*"
}
}
With this setup it's just not possible to use Guzzle6HttpClient
with Guzzle of any version other than 6.
Additionally algolia/algoliasearch-client-php-guzzle7-adapter
can be implemented. Or any other.
Guzzle 7 is now supported on the PHP client, please let us know if you're still facing this issue and reopen the ticket!
Closed without merging?
Hi @reieRMeister, itโs been added in a different PR, #627
Retrying is still not working with Guzzle 7.2.0 and algolia/algoliasearch-client-php 2.7.3.
@chloelbn I'm having an issue, but I have more details I think:
This line wrongly assumes $e
has a hasResponse()
method. But when you fail to connect, there is no response, which means ConnectException
does not have that method. I think the if
clause can simply be dropped here.
EDIT: I think I must be off topic, I'm using v3, and v2 seems to have a wildly different code. I have opened #675 to deal with that.