Receiving status code 520 while trying to fetch metafields for a product ID

DSL
Tourist
6 0 3

Any ideas why I am receiving this response when trying to:

https://shopify.dev/docs/admin-api/rest/reference/metafield?api[version]=2020-04#index-2020-04

Response:

{
"statusCode": 520,
"body": "<html>\r\n<head><title>520 Origin Error</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>520 Origin Error</h1></center>\r\n<hr><center>cloudflare-nginx</center>\r\n</body>\r\n</html>\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n",
"headers": {
"date": "Tue, 26 May 2020 23:04:41 GMT",
"content-type": "text/html",
"content-length": "581",
"connection": "close",
"set-cookie": [
"__cfduid=df06f3ce69470d4575261e22d793e17d91590534217; expires=Thu, 25-Jun-20 23:03:37 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax"
],
"cache-control": "no-store, no-cache",
"cf-cache-status": "DYNAMIC",
"cf-request-id": "02f4d336c00000c99550b08200000001",
"expect-ct": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"server": "cloudflare",
"cf-ray": "599b216ac926c995-SEA",
"alt-svc": "h3-27=\":443\"; ma=86400, h3-25=\":443\"; ma=86400, h3-24=\":443\"; ma=86400, h3-23=\":443\"; ma=86400"
},

DSL
Tourist
6 0 3

Just received this response with the same call to GET a products' metafields:

{
"statusCode": 524,
"body": "<html>\r\n<head><title>524 Origin Time-out</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>524 Origin Time-out</h1></center>\r\n<hr><center>cloudflare-nginx</center>\r\n</body>\r\n</html>\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n<!-- a padding to disable MSIE and Chrome friendly error page -->\r\n",
"headers": {
"date": "Wed, 27 May 2020 20:20:49 GMT",
"content-type": "text/html",
"content-length": "587",
"connection": "close",
"set-cookie": [
"__cfduid=d614f1609b7bda53a732f9aba5f93e1e71590610749; expires=Fri, 26-Jun-20 20:19:09 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax"
],
"cache-control": "no-store, no-cache",
"cf-request-id": "02f96300360000f569a6ac7200000001",
"expect-ct": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"server": "cloudflare",
"cf-ray": "59a26de05b60f569-SEA",
"alt-svc": "h3-27=\":443\"; ma=86400, h3-25=\":443\"; ma=86400, h3-24=\":443\"; ma=86400, h3-23=\":443\"; ma=86400"
},

DSL
Tourist
6 0 3

Am I the only person to get these error messages?

_JB
Shopify Staff
Shopify Staff
834 98 188

Hey @DSL,

 

I'm not familiar with these http_status codes personally, but a quick Google search tells me they're used primarily by Cloudflare.

 

Can you share more details about how you're making this request? As well, if you can you provide the full response headers from the call I can use that to try and find more information in our logs.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Peter_Rhodes
Excursionist
15 1 3

I am also intermittently getting a 524 Origin Time out whenever I make a cURL request to post inventory or pricing to products via API.

Here is the Header/site info I get back:

HTTP/1.1 524 Origin Time-out
Date: Tue, 04 Aug 2020 19:09:53 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Set-Cookie: __cfduid=d4bf718eeee8d593d1b67c2abd5599a1d1596568093; expires=Thu, 03-Sep-20 19:08:13 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax
Cache-Control: no-store, no-cache
cf-request-id: 045c78da490000e99ef694f200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5bda90d6db53e99e-DFW
alt-svc: h3-27=":443"; ma=86400, h3-28=";443"; ma=86400, h3-29=";443"; ma=86400

<html>
<head><title>524 Origin Time-out</title></head>
<body bgcolor="white">
<center><h1>524 Origin Time-out</h1></center>
<hr><center>cloudflare-nginx</center>
</body>
</html>

 

0 Likes
Peter_Rhodes
Excursionist
15 1 3

This is an exaple of one of our "520" errors:

HTTP/1.1 520 Origin Error
Date: Tue, 04 Aug 2020 19:56:00 GMT
Content-Type: text/html
Content-Length: 179
Connection: keep-alive
Set-Cookie: __cfduid=da8a6b18adfc39ebb39b776eaef2a4f9d1596570902; expires=Thu, 03-Sep-20 19:55:02 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax
Cache-Control: no-store, no-cache
CF-Cache-Status: DYNAMIC
cf-request-id: 045ca3b8cb0000d2763e121200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5bdad56e1babd276-DFW
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400

<html>
<head><title>520 Origin Error</title></head>
<body bgcolor="white">
<center><h1>520 Origin Error</h1></center>
<hr><center>cloudflare-nginx</center>
</body>
</html>
0 Likes
_JB
Shopify Staff
Shopify Staff
834 98 188

Hey @Peter_Rhodes,

Far as I can tell these requests aren't hitting Shopify at all. How big are the payloads? I'm not sure what would cause intermittent timeouts like that, but I haven't seen other reports with these error responses. Can you provide the IP of the client making these calls?

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Peter_Rhodes
Excursionist
15 1 3

Hello JB,
Payloads are small.
IP is

Click to expand...
24.160.130.185


I use the Inventory Levels API to send calls like this:

 

POST /admin/inventory_levels/set.json
{
"location_id": 905684977,
"inventory_item_id": 808950810,
"available": 42
}

 




I am running updates for a few hundred/thousand Products/Product Variants
every hour (depends on amounts and types of changes, whether new additions, change in price, or inventory updates)

Updates are mostly successful, but I did get feedback from support that I
am trying to update invalid inventory_ids, and that my JSON data may be
malformed in certain cases:

"I recommend reviewing your endpoints and the contents of the body before making the calls. They are not matching up with the information on your store and are not being formatted correctly. I recommend reviewing our Inventory API guides to make sure you are following the examples as expected."

My primary goal was to attempt to avoid the *5xx *errors, but I now wonder
if Shopify is throwing me off due to a higher than expected number of *4xx *
errors.

Thanks for following up.

0 Likes
_JB
Shopify Staff
Shopify Staff
834 98 188

Hey @Peter_Rhodes,

5XX errors won't be related to any previous requests that received a 4XX response. When your app receives a 5XX response, is it automatically retrying the request again? If so, does the request usually succeed on the next attempt?

I did notice your calls don't include an API version. While this also shouldn't be the cause for 5XX errors, it's one more variable that could perhaps be contributing to unexpected behaviours. We recommend including the API version for all calls, so if possible I would try adding this to see if it makes any difference. Please let me know if you implement this, and what the results are. In the meantime, I'll try running a script against my test store to see if I can replicate the bad gateway errors. I'll let you know if I'm able to replicate errors with that.

 

 

 

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Peter_Rhodes
Excursionist
15 1 3

Hello JB,

5XX errors won't be related to any previous requests that received a 4XX response. When your app receives a 5XX response, is it automatically retrying the request again? If so, does the request usually succeed on the next attempt?

No. I mark items that fail to update and run them later, typically with success. Only rarely are there additional 5xx errors when I do another pass, but when I am running 5 or six "threads" at times, I will have multiple records (about 1 in 10 variants) hit the 5xx wall for about 10-30 seconds before it goes back to normal.

I did notice your calls don't include an API version. While this also shouldn't be the cause for 5XX errors, it's one more variable that could perhaps be contributing to unexpected behaviours. We recommend including the API version for all calls, so if possible I would try adding this to see if it makes any difference. Please let me know if you implement this, and what the results are. In the meantime, I'll try running a script against my test store to see if I can replicate the bad gateway errors. I'll let you know if I'm able to replicate errors with that.

I am working on updating the codebase to include the API version, and I will report back on what I find. Thank you.



 

0 Likes