问题
I have a NodeJS application that integrate with the Gmail API. When I try to access the Gmail API, I get this error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "rateLimitExceeded",
"message": "User-rate limit exceeded. Retry after 2017-03-26T18:15:52.102Z"
}
],
"code": 429,
"message": "User-rate limit exceeded. Retry after 2017-03-26T18:15:52.102Z"
}
}
I was wait for period, and try again, and got same error. I was wait for few hours, saw that is no activity in the API console, I was tried again, and got same error.
回答1:
I think what's happening is you're making too many requests all at the same time. You can see your error in Gmail Per-User Limits. Consider using exponential backoff.
These are the possible reasons you're getting that error:
Concurrent Requests
The Gmail API enforces a per-user concurrent request limit (in addition to the per-user rate limit). This limit is shared by all Gmail API clients accessing a given user and ensures that no API client is overloading a Gmail user mailbox or their backend server.
Making many parallel requests for a single user or sending batches with a large number of requests can trigger this error--as can a large number of independent API clients accessing the Gmail user mailbox simultaneously. If this limit is exceeded a HTTP 429 Too Many Requests "Too many concurrent requests for user" error is returned. Your client may retry the request with standard exponential backoff.
This per-user limit cannot be increased for any reason.
Other reasons may include:
Mail Sending Limits
The Gmail API enforces the standard daily mail sending limits (these limits differ for paying G Suite users vs free gmail.com users).
These limits are per-user and are shared by all of the user's clients, whether API clients, native/web clients or SMTP MSA. If these limits are exceeded a HTTP 429 Too Many Requests "User-rate limit exceeded" error mentioning "(Mail sending)" is returned with a time to retry. Note that daily limits being exceeded may result in these types of errors for multiple hours before the request is accepted, so your client may retry the request with standard exponential backoff.
These per-user limits cannot be increased for any reason.
The mail sending pipeline is complex: once the the user exceeds their quota, there can be a delay of several minutes before the API begins to return 429 error responses. So you cannot assume that a 200 response means the email was successfully sent.
Bandwidth Limits
The API has per-user upload and download bandwidth limits that are the equal to, but independent of, IMAP. These limits are quite generous and are shared across all Gmail API clients for a given user.
These limits are typically only hit in exceptional or abusive situations. If these limits are exceeded a HTTP 429 Too Many Requests "User-rate limit exceeded" error is returned with a time to retry. Note that daily limits being exceeded may result in these types of errors for multiple hours before the request is accepted, so your client may retry the request with standard exponential backoff.
These per-user limits cannot be increased for any reason.
来源:https://stackoverflow.com/questions/43032692/gmail-api-error-429-ratelimitexceeded-even-where-is-no-any-activity