Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
513 views
in Technique[技术] by (71.8m points)

php - How can I find the cause of this intermittent failure / null response from Shopify API when checking inventory levels

While Using a php library (https://github.com/phpclassic/php-shopify) to access the Shopify API I am occasionally getting a Code 520 response from a call to the API endpoint to check inventory levels of a Product / Variants at a specific location. I'm aware that code 520 is Cloudflare notifying me that it got a failed or empty response from the server, I am seeking to understand the cause of the failure.

In general (aside from these occasional failures) the API responses are working well. The call fails at approximate rate of 1 in 1000 calls (but not with a regular interval, but of that order of magnitude). Note: If I log the specifics of the call and manually recreate that exact request it works fine, so it does not seem to be the structure of the call or the payload etc.

Failure response is like this:

PHP Fatal error: Uncaught PHPShopifyExceptionCurlException: Request failed with HTTP Code 520. in /var/www/html/vendor/phpclassic/php-shopify/lib/ShopifyResource.php:489 Stack trace: 
#0 /var/www/html/vendor/phpclassic/php-shopify/lib/ShopifyResource.php(315): PHPShopifyShopifyResource->processResponse(NULL, 'inventory_level...') 
#1 /var/www/html/invconnect/const_inventorypull_shopify.php(308): PHPShopifyShopifyResource->get(Array) 
#2{main}thrown in /var/www/html/vendor/phpclassic/php-shopify/lib/ShopifyResource.php on line 489 
 

Looks like there is a NULL response coming from an inventory level check, the check in question is formed like this:

$params = array([inventory_item_ids] => "3439123438412, 34399123471552, 34399412304023", [location_ids] => "31741235383");

$result= $shopify->InventoryLevel->get($params);

This request is running well for many hundreds of items, and then it will give the response above - any idea how I can debug this or what might be causing it?

The request is rate limited to 1 every 0.6s so should not be a rate limit issue (as leaky bucket allowance allows for 2 requests per second so I should never be depleting allowance).

question from:https://stackoverflow.com/questions/65932484/how-can-i-find-the-cause-of-this-intermittent-failure-null-response-from-shopi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...