Issue in handle_async_request when using Proxy - Connection not being closed when await stream.start_tls(kwargs) raises Error #3217
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The issue occurs in the code block async with Trace("start_tls", logger, request, kwargs). When a request is made to a server without a valid SSL certificate, the **stream = await stream.start_tls(kwargs) line raises an error. Consequently, the connection remains active and isn't closed. The httpx library relies on the httpcore connection pool, doesn't recognize that this connection should be cleaned and reused. Eventually, when all connections are active and unreused, httpx raises a httpx.pooltimeout error. This error is triggered by the **stream = await stream.start_tls(kwargs) line.
Note: The proxy must be set to trigger this error.
To reproduce this issue, set up a self-signed SSL certificate, create an HTTP server, and generate your SSL certificate. The error can be reproduced with the following script (Note: Not all proxies trigger <class 'httpx.ConnectTimeout'> or <class 'httpx.ConnectError'>):
For setting a local proxy. It can be handled by using proxy.py library
Beta Was this translation helpful? Give feedback.
All reactions