NIVANorge/pyniva

PyNIVAError('upstream request timeout'))

Closed this issue · 11 comments

calling pyniva with this code

start_time = "2021-01-09T00:00:00"
end_time = "2023-09-01T15:00:00"
paths_to_download = ['OC/FERRYBOX/FLOW/FLOW/RAW'] 
fb_data = get_data(platform_code, paths_to_download, start_time, end_time, noqc = False)

gives PyNIVAError('upstream request timeout'))

Downloading data for OC
OC/FERRYBOX/FLOW/FLOW/RAW
could not download ('OC/FERRYBOX/FLOW/FLOW/RAW', PyNIVAError('upstream request timeout'))
OC/gpstrack
could not download ('OC/gpstrack', PyNIVAError('upstream request timeout'))
Nothing was downloaded

How can we check what exacly is failing?

I guess this log is related
FetchError: request to http://tsb:5000/?start=2021-01-09T00%3A00%3A00&end=2023-09-01T15%3A00%3A00&noqc=False&dt=0&uuid=48db2bdc-4ce8-4f28-8c94-0e7f98ebcbad failed, reason: socket hang up
at ClientRequest. (/usr/src/app/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (events.js:310:20)
at Socket.socketOnEnd (_http_client.js:453:9)
at Socket.emit (events.js:322:22)
at endReadableNT (_stream_readable.js:1187:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

knl88 commented

clearly related to this commit NIVANorge/ms-ferrybox@045d907

How is that clearly related ? The error comes from tsb, but this commit is in msferrybox.

clearly related to this commit NIVANorge/ms-ferrybox@045d907

How is that clearly related ? The error comes from tsb, but this commit is in msferrybox.

Well, ok. I think it is related, since the amount of data that one is able to request via pyniva went down at the relatively the same time when these changes were introduced.

Can we test?

knl88 commented

yep, lets do that:)

knl88 commented

One error here

knl88 commented

Looks ESPv2 uses a default deadline of 15s, I have increased it in 1bb5746 to 120s. So now

from pyniva import token2header

url="https://ferrybox-api.niva.no/v1/tsb/"
res = requests.get(f"{url}?start=2022-02-01T00%3A00%3A00&end=2023-04-01T16%3A00%3A00&noqc=False&dt=0&uuid=4d9ff393-25a3-47b8-aaf1-8fbbccfec3c3", headers=token2header("niva-service-account.json"))
res

that takes about 46s works.

As a side note @lisapro, I suggest that the get_data functions you create does a check for first and last timestamps to see if the time window can be decreased.

Nice!

By reducing time Window - do you mean splitting the request into shorter time windows?

knl88 commented

Was thinking about first finding the start and end time before running the query, think it is using a bit long time on requests that do not return anything. Yes using some smaller windows is also a good idea 💡but first you need the start and end