Timeout Error: HTTPSConnectionPool ( port=443): Read timed out

Dear All,

I’m setting up a python-Flask prototype (please spin it up by clicking at https://knot-flask.onrender.com).

After spin up, https://knot-flask.onrender.com/api/aziende quickly (3 secs) returns a (public, open) json object - This is to work as a read-only endpoint.

When I call this endpoint from my app (Flask):

apiurl = 'https://knot-flask.onrender.com/api/aziende'   

try:
	rs = requests.get(apiurl, timeout=40,  allow_redirects=True)
	msg	= f"{apiurl}__status_code: {rs.status_code}__" 
	
except requests.exceptions.HTTPError as errh:
	return (f"Http Error: {errh}")
except requests.exceptions.ConnectionError as errc:
	return (f"Error Connecting: {errc}")
except requests.exceptions.Timeout as errt:
	return (f"Timeout Error: {errt}")
except requests.exceptions.RequestException as err:
	return (f"OOps: Something Else: {err}")

I get “Timeout Error: HTTPSConnectionPool(host=‘knot-flask.onrender.com’, port=443): Read timed out. (read timeout=40)”

You can replicate this at https://knot-flask.onrender.com/elenco_aziende

Any clue how to solve this issue?
Thanks in advance,
Pedro Pimenta

Hi there,

Have you tried increasing the timeout value? It may be that the more limited resources on your Render service (than on your development machine) is taking longer to process the request and return the JSON file. Increasing the timeout value will hopefully help give the service enough time to return the file and thus no longer time out.

Another option would be to try out upgrading to a paid instance type with more resources, so the file may get processed and then returned faster.

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

Hi Mike!
Thanks for your insight!

Yes, I did increase the timeout :hourglass_flowing_sand: (timeout=40) - however, this sounds fishy to me, since we know the endpoint answers in 3~4 seconds :exploding_head: (and the payload is quite light) - I already tried to set timeout=120 and the result is the same - sure, I can try to increase it a bit more :crazy_face:, but it sounds strange to me…

By checking my code dont you see any other alternative?

Sure, I can switch to a payed instance, but I would be very disapointed if the situations remains :face_with_diagonal_mouth:

Thanks for your help :ok_hand:

Hi there,

Just for clarification, are you referring to the same endpoint regarding a 3 second response and the timeout? Perhaps describe in more detail the sequence of events that leads to the timeout?

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

Sure @Mike_Marinaro, I do:
… so, the sequence is:

  1. please spin the prototype by clicking at https://knot-flask.onrender.com) - this can take a lot of time, but after that;

  2. check that https://knot-flask.onrender.com/api/aziende answers really quickly (<4 secs)

  3. Try https://knot-flask.onrender.com/elenco_aziende - which calls https://knot-flask.onrender.com/api/aziende using ~requests~:

apiurl = ‘https://knot-flask.onrender.com/api/aziende

try:
rs = requests.get(apiurl, timeout=40, allow_redirects=True)
msg = f"{apiurl}status_code: {rs.status_code}"

except requests.exceptions.HTTPError as errh:
return (f"Http Error: {errh}“)
except requests.exceptions.ConnectionError as errc:
return (f"Error Connecting: {errc}”)
except requests.exceptions.Timeout as errt:
return (f"Timeout Error: {errt}“)
except requests.exceptions.RequestException as err:
return (f"OOps: Something Else: {err}”)^

we get “Timeout Error: HTTPSConnectionPool(host=‘knot-flask.onrender.com’, port=443): Read timed out. (read timeout=40)”

:face_with_head_bandage:

Thanks for your care!

Hi there,

I can reproduce the behavior you are describing. Out of curiosity, why is your app calling itself at a different endpoint over HTTPS? When you call /elenco_aziende why not just have the code internally route to the underlying code for /api/aziende? Is there a particular reason why the code can’t remain internal and instead must fetch data over another public API call within the same service?

Beyond that suggestion, you would need to reach out to us privately (via the Help link in the Render Dashboard) for us to be able to take a closer look at this service. Be sure to provide the service name or id.

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

Hi @Mike_Marinaro,
Thank you very much for your care and attention.

Out of curiosity, why is your app calling itself at a different endpoint over HTTPS?

I’m setting up a ‘database’, and since I want to make the data public through the API - /api/aziende - I want to be the first to consume and use that same data to build my html pages -

Sure, I can fectch the data ‘directly’, but that way I loose part of the fun :slightly_smiling_face:

Thanks for the Help link suggestion, I will head for it now.
All the best,
Pedro Pimenta

Thanks for explaining! Closing this community thread.

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.