Issue in handle_async_request when using Proxy - Connection not being closed when await stream.start_tls(kwargs) raises Error #921
Replies: 1 comment
-
|
Placing my raw story here - same as above In my case I am observing the following behavior. From time to time I did some debugging and looks to me the If that repeated as many times as many connections are allowed the pool can no create any new one and will always throw It is trivial to reproduce when debugging with low connect timeout setting. Place breakpoint in here and wait longer then the timeout value. That will raise The My proposal is to try/catch the lines 299 and 326 and close tunnel, e.g. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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