-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle ClientResponseError/ServerDisconnectedError properly #850
Comments
I had similar problem and I was hoping that aiohttp could have a retry logic on connection errors and possible on HTTP status. Because there isn't just thing yet available I came up with the following which works for REST APIs where json is returned::
|
wow. great, Thanks! |
Don't forget to adjust the parsing of the json as it is very specific to my needs. |
My question is whether this error is related only to this library, and should thus always be ignored/caught/retried, or whether I should expect that this error could also be due to something server-sided? |
The exception is raised when a peer had closed the socket. |
Try setting the client to tell the server to close the connection after each request:
HTTP keep-alive allows the same connection to be used for multiple requests, which can improve performance, especially over HTTPS, where the connection handshake can be lengthy. But the server may have a limit as to how long it's willing to keep the connection alive or how many requests it will accept on the same connection. When the limit runs out, it closes the connection. |
Hi,
It's not a bug, but a question. I am using this library to load a lot of http-files over a proxy. After some successful requests I always get a ServerDisconnectedError.
Is there a way to enable some sort of "auto-reconnect" and what is the recommended technique to handle this error?
The text was updated successfully, but these errors were encountered: