Replies: 1 comment 2 replies
-
First, it would be good to use ClientTimeout as documented, not the deprecated int format. But, my best guess is that because this is a total timeout, the cause may not be network related, but you may have blocking code that's stopping aiohttp from returning to the request in time. e.g. If you start the request, but have 60+ tasks queued in the event loop, which all take a full second of blocking code to run, then it won't get back to the request before the timeout period is reached. If you've not done so already, I suggest using debug mode during development which will create warnings if any code blocks the event loop for more than 100ms: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using FastAPI via GCP Cloud Run where a
aiohttp.ClientSession
is created on application startup (aiohttp 3.12.15).Infrequently I see
asyncio.TimeoutError
raised after 60 seconds given the following code:I have been discussing these timeouts with the third party API. From their logs, the response fulfilled in 2/3 seconds but they do see a 460 status code (AWS) which means the client connection was closed/terminated.
So far I've been unable to replicate, I've tried tweaking TLS & socket settings to no avail.
99% of the time requests work as expected but I have occasional timeouts even though the third party says all looks good their end.
Does anyone have any advice what to try next or how to debug further?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions