Forums

Connection reset by peer, async edition

Hi, my application is doing a lot of async, and sometimes it falls down with this error:

aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer

The async code is calling a Google Cloud Function many times. Can you point me in the right direction? Any thoughts on what might be causing this?

How many times is is calling the function? If you're really hammering their servers with requests, there's a chance that they might start rate-limiting you at a low level by resetting new connections.

An alternative problem might be if your code is somehow opening up a connection and trying to keep it open for a long time, and then it's being closed on the server side due to inactivity; you could perhaps try logging when particular connections were opened and see if the ones that trigger that error are ones that have been open for a long time.

Thanks. For now I've dealt with this by handling the error when it comes up. We'll see how it goes. It seems to be a problem when there's a lot of traffic to my page.