phpclassic / php-shopify

PHP SDK for Shopify API
Apache License 2.0
568 stars 211 forks source link

Intermittent Code 520 response on checking InventoryLevel via line 315 of ShopifyResource.php #207

Open DataDeveloped opened 3 years ago

DataDeveloped commented 3 years ago

Hi team,

Thank you for the library - it is very useful!

I'm getting this response to a request occasionally during a looped inventory check on a store.

PHP Fatal error: Uncaught PHPShopify\Exception\CurlException: 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): PHPShopify\ShopifyResource->processResponse(NULL, 'inventory_level...') #1 /var/www/html/invconnect/const_inventorypull_shopify.php(308): PHPShopify\ShopifyResource->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.

fabio-sassi-spotview commented 2 years ago

Hi @DataDeveloped

This is a "common" shopify issue, sometimes request fail, I found same error in my log:

Request failed with HTTP Code 520
Request failed with HTTP Code 503
OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104

If you try again a moment later, same request is ok (I write a pull request to mitigate this problem #240 )