简体   繁体   English

使用C#MCV的GMail API超出了用户速率限制

[英]User-rate limit exceeded for GMail API using C# MCV

Can anyone help me to get the solution User-rate limit exceeded for GMail API using C# MCV application. 谁能帮助我获得解决方案使用C#MCV应用程序的GMail API超出了用户速率限制。 I am stuck with this since last 5 days. 自最近5天以来,我一直坚持这一点。 There was no document in internet. 互联网上没有文件。 No solution from google also. 谷歌也没有解决方案。 I have billing enabled for access the google service. 我已启用结算功能以访问Google服务。 Using the code like... 使用类似...的代码

var certificate = new X509Certificate2(AssemblyDirectory + string.Format("\\{0}",CertificateFileName), CertificatePassword, X509KeyStorageFlags.Exportable);

ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(ServiceAccountEmail)
               {
                   Scopes = new[] { GmailService.Scope.GmailModify },
                   User=this.User
               }.FromCertificate(certificate));

 // Create the service.
 service = new GmailService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = this.ApplicationName,
                ApiKey="xxxxxxxxxxxxxxxxxxx",
            }); 

ListLabelsResponse response = service.Users.Labels.List("me").Execute();
Labels = response.Labels.ToList();
if (!Labels.Select(l => l.Name).Contains("Processed"))
    {
         Labels.Add(CreateLabel("Processed"));
    }

Explanation 说明

User-rate limit error messages are flood protection. 用户速率限制错误消息具有防洪功能。 The current user you are logged in as this being your service account can only make X number of requests a minute / second 您目前登录的当前用户是您的服务帐户,因此一分钟/秒只能发出X个请求

在此处输入图片说明

As you can see the user can max make 25,000 queries in 100 seconds. 如您所见,用户最多可以在100秒内进行25,000个查询。 Your application can make a max of 2,000,000 requests in 100 seconds. 您的应用程序最多可以在100秒内发出2,000,000个请求。 Gmail also has some other limits with recard to mail sending which have not been documented. Gmail还具有其他一些限制,即记录发送邮件的方式无法记录。

There is nothing you can do when you hit the user rate limit quota besides slow your application down. 达到用户速率限制配额时,除了降低应用程序速度之外,您无能为力。

Standard error messages 标准错误消息

403: User Rate Limit Exceeded The per-user limit has been reached. 403:超出用户速率限制已达到每用户限制。 This may be the limit from the Developer Console or a limit from the Drive backend. 这可能是开发者控制台的限制,也可能是云端硬盘后端的限制。

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "userRateLimitExceeded",
    "message": "User Rate Limit Exceeded"
   }
  ],
  "code": 403,
  "message": "User Rate Limit Exceeded"
 }
}

Suggested actions: 建议采取的措施:

Use exponential backoff. 使用指数补偿。

403: Rate Limit Exceeded The user has reached Google Drive API's maximum request rate. 403:超出速率限制用户已达到Google Drive API的最大请求速率。 The limit varies depending on the kind of requests. 该限制取决于请求的类型。

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "message": "Rate Limit Exceeded",
    "reason": "rateLimitExceeded",
   }
  ],
  "code": 403,
  "message": "Rate Limit Exceeded"
 }
}

Suggested actions: 建议采取的措施:

Use exponential backoff. 使用指数补偿。

Implementing exponential backoff 实施指数补偿

Exponential backoff is a standard error handling strategy for network applications in which the client periodically retries a failed request over an increasing amount of time. 指数补偿是网络应用程序的标准错误处理策略,在该策略中,客户端会在越来越多的时间内定期重试失败的请求。 If a high volume of requests or heavy network traffic causes the server to return errors, exponential backoff may be a good strategy for handling those errors. 如果大量请求或繁重的网络流量导致服务器返回错误,则指数退避可能是处理这些错误的好策略。 Conversely, it is not a relevant strategy for dealing with errors unrelated to rate-limiting, network volume or response times, such as invalid authorization credentials or file not found errors. 相反,它不是处理与速率限制,网络量或响应时间无关的错误(例如无效的授权凭据或找不到文件的错误)的相关策略。

Used properly, exponential backoff increases the efficiency of bandwidth usage, reduces the number of requests required to get a successful response, and maximizes the throughput of requests in concurrent environments. 正确地使用指数补偿可以提高带宽使用效率,减少获得成功响应所需的请求数量,并在并发环境中最大化请求的吞吐量。

Create requests are not idempotent. 创建请求不是幂等的。 A simple retry is insufficient and may result in duplicate entities. 简单的重试是不够的,可能会导致实体重复。 Check whether the entity exists before retrying. 重试之前,请检查该实体是否存在。

Billing 开票

It is not possible to increase the user rate limits they are there to keep developers from flooding Googles servers. 无法提高用户速率限制,以防止开发人员淹没Google的服务器。 Gmail API is free enabling billing isn't going to do much. Gmail API是免费的,启用计费不会做太多事情。

Note 注意

TBH i would be surprised if you are getting this from doing a Users.Labels.List("me") unless you have this code running for every user hitting your website rather than caching the data. TBH如果您是通过执行Users.Labels.List("me")获得此信息的,我将感到惊讶,除非您为访问您网站的每个用户运行此代码,而不是缓存数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gmail API - 超出速率限制 [429],后端错误 [500] - Gmail API - Rate Limit Exceeded [429], Backend Error [500] 毫无疑问地超过了API用户速率限制[403] - Translate API User Rate Limit Exceeded [403] without reason 如果使用WebApiThrottle超过API速率限制,则将API请求阻止5分钟-C#Web API - Block API requests for 5 mins if API rate limit exceeds using WebApiThrottle - C# Web API 在 C# 中限制客户端 api 的最佳方法 - Best way to rate limit clientside api in C# c# 服务用于 Shopify 管理员 API 集成速率限制问题 - c# service for Shopify Admin API integration rate limit issue 如何在C#中使用Gmail API获取Gmail主题 - How to get Gmail subjects using Gmail API in C# Echo Nest API:将curl命令转换为用于检查速率限制的C# - Echo Nest API: convert curl command for checking rate limit to c# 在递归中使用Math.Pow()时,执行时间超过了c# - Execution time limit was exceeded c#, while using Math.Pow() in recursion 使用 C# 从 GridFS 下载大文件给出 Sort exceeded memory limit 错误 - Downloading a large file from GridFS using C# gives Sort exceeded memory limit error 如何使用 C# 识别私有消息队列 (MSMQ) 是否已超出其消息存储限制? - How to identify if a private message queue (MSMQ) has exceeded its message storage limit using C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM