httpx
httpx copied to clipboard
timeout not respected with socks5 proxy
trafficstars
I am also experiencing this issue. The timeout property has no effect on reads with SOCKS5 proxies, while the same functionality works as expected with HTTP proxies.
Discussed in https://github.com/encode/httpx/discussions/2951
Originally posted by a14n November 20, 2023
With httpx[socks]==0.23.3and the following code an httpx.ReadTimeout is raised only with https proxy and not with socks5 proxy. Is it an known issue?
async def main():
async_client = httpx.AsyncClient(
# proxies="https://my-https-proxy:443",
proxies="socks5://my-socks5-proxy:3128",
follow_redirects=True,
timeout=1,
)
start = time.time_ns()
try:
response = await async_client.get(
"http://www.protesa.net/",
follow_redirects=False,
)
print("status", response.status_code)
except Exception as e:
print("ex", type(e))
# traceback.print_exc()
finally:
print(f"{time.time_ns() - start}ns")
await async_client.aclose()
if __name__ == '__main__':
asyncio.run(main())
The output for socks5 proxy is:
ex <class 'socksio.exceptions.ProtocolError'>
59288033291ns
The output for http proxy is:
ex <class 'httpx.ReadTimeout'>
1345715709ns
```</div>