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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…