aiohttp
aiohttp copied to clipboard
Broken timeout system with ws_connect
Describe the bug
Context
We have very specific requirements with our HTTP connections: we expect extremely responsive API and reconnect rapidly if we don't receive responses because we consider it a potential failure.
To facilitate that we use ClientTimeout(connect=1.5, sock_connect=1.0, sock_read=0.5)
, i.e. yes, if we attempt to read on a socket after sending the request and nothing arrives in 500 ms we consider it a failure and perform a retry.
Problem
This actually works great except when we use the ws_connect
for websockets. Having nothing to read for 0.5s of sock_read
results in a ServerTimeoutError
requiring to retry with ws_connect
.
Problem, however, is that ws_connect
's timeout
and receive_timeout
have no effect on the underlying timeout configuration because _ws_connect
's call to self.request
does not alter the receive timeout for the connection by calling conn.protocol.set_response_params
. And after the WSS connection is established, disregarding the ws_connect
's receive_timeout
the protocol inherits the parent's HTTP connection's sock_read
of 0.5.
To Reproduce
Above
Expected behavior
receive_timeout
passed to the ws_connect
should be observed, by calling conn.protocol.set_response_params
with receive_timeout
as read_timeout
Logs/tracebacks
N/A
Python Version
N/A
aiohttp Version
Latest stable
multidict Version
N/A
yarl Version
N/A
OS
OS-independent
Related component
Client
Additional context
No response
Code of Conduct
- [X] I agree to follow the aio-libs Code of Conduct