-
Notifications
You must be signed in to change notification settings - Fork 211
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Handling rate limits #277
Comments
@Ronnie-J - Thanks for the report here. We use the Guzzle HTTP library for our requests and that handles the exceptions, including the 429 rate limit response. Here's a quick sample of how you can handle that on your end: try {
// Rate limit triggering code
} catch ( ClientException $e ) {
// Will contain the API token used, which is very sentitive.
echo GuzzleHttp\Psr7\str( $e->getRequest() ) . '<br>';
// This is the response which contains the headers you're looking for ... outputting as a string here but you probably want to parse this differently.
echo GuzzleHttp\Psr7\str( $e->getResponse() ). '<br>';
// Actual response from the server
echo $e->getMessage() . '<br>';
// Error code for a rate limit, 429
echo $e->getCode() . '<br>';
} Request:
Response:
Message:
Code:
|
Makes sense @joshcanhelp but I would still like to handle stuff in advance. The Or am I missing something obvious? |
@joshcanhelp I think it would be a great contribution to the library if you were able to work with the rate-limits before the line is crossed and it's going to be an exception. |
@Ronnie-J - Absolutely. I'll do a little leg work this week and see how big of a job this will be. |
I did a little research here and I don't think this will be too big of a job. I'd like to add this without cluttering up the interface too much but it can be done without breaking changes and I think it will be an useful feature. Re-opening now and will get it into an upcoming sprint for completion. Thanks again for the report @Ronnie-J |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi.
As I can tell using the library there is no real way of handling the rate limits from the Management and Authentication API.
An exception is thrown but I have no way of telling what the headers are from the response or even handle the situation in advance by taking actions accordingly.
Any thoughts?
The text was updated successfully, but these errors were encountered: