Comments (15)
I need more information to answer that. It could be something simple (e.g. PHP version too old).
If you provide a code example and your PHP version, I might be able to pin it down.
from guzzle-advanced-throttle.
$options = [
'base_uri' => 'https://api.entstix.com/api/v1/xlive/',
'headers' => [
'Accept-Language' => 'en',
],
'auth' => ['username', 'password'],
];
$stack = HandlerStack::create();
$client = GuzzleThrottle::client(array_merge($options, ['handler' => $stack]);
$response = $client->get('content/attraction');
echo $response->getBody()->getContents();
and the result is
but, changing
$client = GuzzleThrottle::client(array_merge($options, ['handler' => $stack]);
in
$client = new \GuzzleHttp\Client(array_merge($options, ['handler' => $stack]);
get everything works fine
from guzzle-advanced-throttle.
I'm running on laravel/homestead latest version
from guzzle-advanced-throttle.
Ah, so you are using the Laravel wrapper. There might be a problem with how you initialize the handler stack. Maybe you can try it with new HandlerStack()
instead of HandlerStack::create()
(I don't know if it makes a difference, though). Another thing to try first would be to see if it makes a difference to pass the array directly instead of using array_merge
.
But I'll have a look this evening when I'm home. Shouldn't be that hard to find the issue :)
from guzzle-advanced-throttle.
Thank you
Yes I tried with the bridge and without, with array merge and without (no issue here) and with new HandlerStack or with HandlerStack::create (same issue)
The only thing get things work is use the standard Guzzle Client. Adding the throttle middlewere get things broke.
from guzzle-advanced-throttle.
It would be helpful if you could provide me the config you use for the middleware. Then it's easier to debug it later (the one you created with vendor:publish
).
from guzzle-advanced-throttle.
Sure
<?php
// @codeCoverageIgnoreStart
// example configuration
return [
'cache' => [
// Name of the configured driver in the Laravel cache config file / Also needs to be set when "no-cache" is set! Because it's used for the internal timers
'driver' => env('CACHE_DRIVER'),
// Cache strategy: no-cache, cache, force-cache
'strategy' => 'force-cache',
// TTL in minutes
'ttl' => 900,
],
'rules' => [
// host (including scheme)
'https://api.getyourguide.com' => [
[
// maximum number of requests in the given interval
'max_requests' => 600,
// interval in seconds till the limit is reset
'request_interval' => 60,
],
],
/**
* @see https://mail.mixmax.com/m/sjn5eJw7arzyEEW4Z
*/
'https://prelive.viatorapi.viator.com' => [
[
'max_requests' => 15,
'request_interval' => 10,
],
],
/**
* @see https://mail.mixmax.com/m/sjn5eJw7arzyEEW4Z
*/
'https://viatorapi.viator.com' => [
[
'max_requests' => 45,
'request_interval' => 10,
],
],
],
];
// @codeCoverageIgnoreEnd
the cache driver is redis, but same issue on file drive
from guzzle-advanced-throttle.
I think it is a problem with the authorization. If I use your exact configuration with another endpoint that doesn't require auth it works perfectly. I don't have permission to access https://api.entstix.com/api/v1/xlive/
.
I can set up an environment that requires authentication tomorrow and check what the root cause is.
from guzzle-advanced-throttle.
Thank you
Let me know if you need that auth credentials
from guzzle-advanced-throttle.
I just had another look at it. I think the stream is at a wrong position and not rewinded correctly in that case.
Can you try to get the contents with echo (string) $response->getBody();
and report back what it returns?
from guzzle-advanced-throttle.
Yes, it works!
Why instead with the middle ...->getContents() got error?
from guzzle-advanced-throttle.
getBody
will always return the whole response body, see https://guzzle3.readthedocs.io/http-client/response.html#response-body or in the new documentation here: http://docs.guzzlephp.org/en/stable/psr7.html?highlight=getbody#body
getContents
returns the response body from the current position of the stream/file pointer.
I'll create a new issue for that later when I'm home. But I won't be able to fix that behavior before next week, sorry.
from guzzle-advanced-throttle.
Ouch, thanks for the explanation!
from guzzle-advanced-throttle.
Doesn't seem like an easy fix.
The logging middleware has similar problems (see guzzle/guzzle#1582).
Gonna close this for now.
from guzzle-advanced-throttle.
Okay
The casting anyway solved my problem
from guzzle-advanced-throttle.
Related Issues (8)
- Host definitions with wildcards
- Allow to use other implementations of StorageInterface and Cacheable
- Cache driver default doesn't use env CACHE_DRIVER HOT 3
- Let script u_sleep() before 429 status showed up
- Respect request parameters for caching
- Improve configuration (avoid duplication)
- Problem with Laravel cache drivers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guzzle-advanced-throttle.