简体   繁体   English

c# 服务用于 Shopify 管理员 API 集成速率限制问题

[英]c# service for Shopify Admin API integration rate limit issue

I build a Shopify integration over 3 months ago and I can't seem to finish how to manage the rate limit.我在 3 个月前构建了 Shopify 集成,但我似乎无法完成如何管理速率限制。 I used a simple Task.WaitAll with a list of tasks sent to Shopify and had a limit of request at the time but I still got with 429 rate limit error or task cancellation error.我使用了一个简单的 Task.WaitAll 和一个发送到 Shopify 的任务列表,并且当时有一个请求限制,但我仍然遇到 429 速率限制错误或任务取消错误。 Now I'm using TokenBucket nugget package and I am getting task cancellation error all the time and nothing seems to sync.现在我正在使用 TokenBucket nugget package,我一直收到任务取消错误,似乎没有同步。 Honestly, I'm very frustrated and about to throw the project out the window unless maybe someone can give me a hint how I can fix this.老实说,我非常沮丧,即将把项目从 window 中抛出,除非有人可以给我一个提示,我该如何解决这个问题。 Tnx in advanced... Tnx 在高级...

You should take a look at your C# responses from Shopify, particularly, the headers.您应该查看来自 Shopify 的 C# 响应,特别是标题。 Every header Shopify sends you has rate limit information.每个 header Shopify 发送给您的都有速率限制信息。 Before they send you a dreaded 429 error, they are showing you how many requests you can make before you run out.在他们向您发送可怕的 429 错误之前,他们会向您展示在您用完之前可以发出多少请求。 So if you are able to examine your headers, that is where you can put some logic in to deal with rate limits.因此,如果您能够检查您的标头,那么您可以在其中放入一些逻辑来处理速率限制。 Since Shopify adds to your limit when you stop making calls, when your limit approaches zero, you can simply rest a bit, wait, sleep, whatever you call it and then start back up with new limits.由于 Shopify 在您停止拨打电话时会增加您的限制,因此当您的限制接近零时,您可以简单地 rest 一点,等待,睡眠,无论您怎么称呼它,然后以新的限制重新开始。

I am sure C# has a simple hack for this already built in to the code used to make HTTPS calls.我确信 C# 有一个简单的 hack 已经内置到用于进行 HTTPS 调用的代码中。 It is not like rate limiting is new, rare or unique to Shopify, it is used everywhere.速率限制并不是 Shopify 的新的、罕见的或独有的,它无处不在。 In fact, there are probably C# hacks for Shopify that do what you need.事实上,Shopify 的 C# hack 可以满足您的需求。 Have you tried looking for any?你试过寻找吗?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM