Code 502 from server

Hello,

Periodically when sending a query to the API, the Python requests library gets back a response code of 502. It’s basically a total failure when trying to send the query as there’s no data that actually comes back from the API, and therefore no request_id to reference.

Often times this will happen when the script is paginating through the long results set of a query. For example, I have one that uses the picks_per_day query and gets everything from the previous working day. In total there may be around 2000 records to download, and it will be going fine and then all of a sudden around the 8th page, for example, it will throw the 502 error. If I rerun the script, t will work fine. It’s like there’s a momentary hiccup in the API server and then it works again, but it’s enough to throw off the script.

So I guess my question is what is causing this 502 error, and is there any simple way around it?

Thanks,
Jeremy

1 Like

Just a bump. I got this again this morning. Can anyone give any insight?

Thanks.

Bump. Having the same issue while fetching product data. In my case it’s happening very often. Sometimes even when fetching the 1st page.

Hi guys, sorry for the delay. @jeremyw this has been happening on the picks query only? could you share the query please?
@mpspw could you please share the query? is it only with products?

thanks!

Hi Seba,

The direct answer to your question is “yes”, I’ve only seen it happening on the picks_per_day query, but then again, it’s the only query where I’m actively monitoring the results. So, it could be happening elsewhere and I just haven’t seen it yet. Considering that mpspw has been seeing something similar on the products query, I’m guessing it’s not limited to picks_per_day.

My query is as follows:

query($timestamp: ISODateTime, $cursor: String, $record_count: Int) {
    picks_per_day(date_from: $timestamp) {
        request_id
        complexity
        data(after: $cursor, first: $record_count, sort: "created_at") {
            pageInfo {
                hasPreviousPage
                hasNextPage
                endCursor
            }
            edges {
                cursor
                node {
                    id
                    user_first_name
                    user_last_name
                    order_number
                    sku
                    picked_quantity
                    inventory_bin
                    barcode_scanned
                    created_at
                }
            }
        }
    }
}

Thanks!

Hi @seba It happens randomly, even when trying to acquire the access token or when refreshing token. I noticed it more on the product/products as these are the ones i have been messing around the most with lately.
Below are two example queries that returned said error.
Product:

query {
product(sku: “TESTPRODUCT”) {
complexity
request_id
data {
id
legacy_id
name
sku
barcode
country_of_manufacture
dimensions {
weight
height
width
length
}
tariff_code
kit
kit
no_air
final_sale
customs_value
customs_description
not_owned
dropship
needs_serial_number
thumbnail
large_thumbnail
created_at
updated_at
warehouse_products {
id
warehouse_id
on_hand
}
images {
src
position
}
tags
vendors {
vendor_id
vendor_sku
}
components {
id
}
}
}
}

Products:

query {
products {
complexity,
request_id
data(first:100, after:“YXJyYXljb25uZWN0aW9uOjk5”,) {
pageInfo {
startCursor,
endCursor,
hasNextPage,
hasPreviousPage
}
edges {
cursor
node {
id,
legacy_id,
name,
sku,
barcode,
country_of_manufacture,
dimensions {
weight,
height,
width,
length
}
tariff_code,
kit,
no_air,
final_sale,
customs_value,
customs_description,
not_owned,
dropship,
needs_serial_number,
thumbnail,
large_thumbnail,
created_at,
updated_at,
warehouse_products {
id,
warehouse_id,
on_hand
}
images {
src,
position
}
tags,
vendors {
vendor_id,
vendor_sku
}
components {
id,
sku
}
}
}
}
}
}

I also noticed it happening when fetching the schema when using Insomnia GraphQL client (as seen in the image below).
Screenshot%20from%202019-11-19%2008-55-54

We are looking into it, will keep you posted. Please let us know if you keep experiencing this 502 or if you stop getting those. Thanks!

@seba Just letting you know that the error keeps happening randomly but often for me, no matter if i’m fetching Shiphero data through code or if i’m just using the GraphQL client (when getting the schema also, as mentioned in my previous post).

Good morning, @seba!

This morning around 7:24am EST, Nov 29, I received another 502 error.

35%20AM

Good morning, @seba!

This morning around 7am EST, Dec 3, I got another 502 error. It looks exactly the same as above. It came up after successfully pulling down 4400 picks. And I forgot to mention the other day it had pulled 5000 picks before giving the error.

Thanks,
Jeremy

Thanks guys, we are looking at the issue, it doesn’t seem to happen that often but we do have so possible improvements that we are going to try (have been busy with BF/CM). Will keep you posted.

1 Like

Hello @seba,

we’re also getting this issue from seemingly at random while checking inventory. Since we’re paginating here this can break the entire call. Unfortunately I’m unable to set up retrys with our current system.
image
Could you please give us a status update on the issue?

Best
Stefan

1 Like

Hi @seba,

I’m still seeing this issue, and this morning I even got a 504 Gateway Timeout error instead of a 502. Do you know if there’s been any update on this?

Thanks,
Jeremy

1 Like

Joining in on this - I seem to get the same 502 error frequently as well. It might be as much as 5% or more of calls I make.

I’ve come up with a workaround if you run into this while paginating. While looping through the pages, if it returns a 502 status code, just repeat the exact same request again. I made my call function very modular, so if response = 502 then call the same function passing the same parameters into it. If it is a success, then pass along next page info!

It is a bit of custom code, but I’ve found it good to use for almost any integration, as 502s can sporadically appear and shouldn’t disrupt you!

2 Likes

Just to chime in as well, I am continuing to see 502 errors periodically (periodically is daily, but the majority of calls are successful).

Most of these are seen an product queries.

Qualitatively, these seems to happen the most when we make a large consecutive series of calls.

1 Like

Hey All, Like this?

I get it when paginating orders and when paginating line items for those orders.

I’ve compensated by retrying after a reasonable amount of time and it hasn’t failed again after that interval yet, but it does add some complexity. Errors can happen with any service but they do happen pretty regularly when making a consecutive series of calls like @david says. Products for him, orders/line items for me, and picks per day for @jeremyw.

2 Likes

It has been approximately 3 months. Are there any updates?

Regarding “it doesn’t seem to happen that often”… it happens multiple times per day.

1 Like

Sorry for the inconvenience, our devops team is working on this as we speak. We will probably have some news in a couple of weeks, so we will keep you posted.