ssl.SSLWantReadError / httpx.ReadTimeout appearing randomly #2941
Replies: 4 comments 21 replies
-
Ah correction, it doesn't need to be batched. This still reproduces the issue: async def main() -> None:
try:
while True:
for _ in range(20):
await make_request()
print(f"total reqs {total}")
finally:
print(f"total reqs {total}") |
Beta Was this translation helpful? Give feedback.
-
Looks like redis-py had a similar issue and fixed it by ignoring the ssl.SSLWantReadError (I think) redis/redis-py@e897c17 Related report here: #2615 (comment) Found a reference to this error in another library: dpallot/simple-websocket-server#100, the solution in that PR was to retry... |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
So, what is the solution here? Should we add retry to take care of this? |
Beta Was this translation helpful? Give feedback.
-
When continually making requests to the OpenAI API, it will eventually fail with a
httpx.ReadTimeout
error that is caused by anssl.SSLWantReadError
error.Here's an example script:
This eventually fails for me from anywhere between 1 and 1.3k requests.
Stack trace
For context, I'm trying to reproduce an issue reported by users of the
openai-python
library that useshttpx
under the hood. openai/openai-python#769This also happens when:
with httpx.Client(limits=httpx.Limits(max_connections=1))
v0.23.0
orv0.18.0
verify=False
I haven't verified that this independently of the OpenAI API yet so it could be an API issue but thats very unlikely as users have reported downgrading to an older version that doesn't use httpx which fixes the issue. I have also repeatedly made requests using
node-fetch
which succeeded.I have attempted to reproduce this without using the OpenAI API under the following conditions, all of which did not successfully reproduce the issue:
respx
to mock the responseprism
mock server under http (not https)Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions