troubleshooting.md
This file
Path
docs/troubleshooting.md
63 lines · 2.1 KiB · Markdown
Last changed by
Add the 'proxy' parameter and deprecate 'proxies'. (#2879)Kar Petrosyanbefore adoptionf8981f3
History of this fileTake it
The walk stopped after 200 commits: lines older than 8088fc7 point at it.
Test under 3.11-dev (#2302)Jobefore adoption8088fc7
lines 1–21why, one step back1# Troubleshooting23This page lists some common problems or issues you could encounter while developing with HTTPX, as well as possible solutions.45## Proxies67---89### "`The handshake operation timed out`" on HTTPS requests when using a proxy1011**Description**: When using a proxy and making an HTTPS request, you see an exception looking like this:1213```console14httpx.ProxyError: _ssl.c:1091: The handshake operation timed out15```1617**Similar issues**: [encode/httpx#1412](https://github.com/encode/httpx/issues/1412), [encode/httpx#1433](https://github.com/encode/httpx/issues/1433)1819**Resolution**: it is likely that you've set up your proxies like this...2021```pythonAdd the 'proxy' parameter and deprecate 'proxies'. (#2879)Kar Petrosyanbefore adoptionf8981f3
lines 22–24why, one step back22mounts = {23 "http://": httpx.HTTPTransport(proxy="http://myproxy.org"),24 "https://": httpx.HTTPTransport(proxy="https://myproxy.org"),Test under 3.11-dev (#2302)Jobefore adoption8088fc7
lines 25–34why, one step back25}26```2728Using this setup, you're telling HTTPX to connect to the proxy using HTTP for HTTP requests, and using HTTPS for HTTPS requests.2930But if you get the error above, it is likely that your proxy doesn't support connecting via HTTPS. Don't worry: that's a [common gotcha](advanced.md#example).3132Change the scheme of your HTTPS proxy to `http://...` instead of `https://...`:3334```pythonAdd the 'proxy' parameter and deprecate 'proxies'. (#2879)Kar Petrosyanbefore adoptionf8981f3
lines 35–37why, one step back35mounts = {36 "http://": httpx.HTTPTransport(proxy="http://myproxy.org"),37 "https://": httpx.HTTPTransport(proxy="http://myproxy.org"),Test under 3.11-dev (#2302)Jobefore adoption8088fc7
lines 38–43why, one step back38}39```4041This can be simplified to:4243```pythonAdd the 'proxy' parameter and deprecate 'proxies'. (#2879)Kar Petrosyanbefore adoptionf8981f3
lines 44–46why, one step back44proxy = "http://myproxy.org"45with httpx.Client(proxy=proxy) as client:46 ...Test under 3.11-dev (#2302)Jobefore adoption8088fc7
lines 47–63why, one step back47```4849For more information, see [Proxies: FORWARD vs TUNNEL](advanced.md#forward-vs-tunnel).5051---5253### Error when making requests to an HTTPS proxy5455**Description**: your proxy _does_ support connecting via HTTPS, but you are seeing errors along the lines of...5657```console58httpx.ProxyError: [SSL: PRE_MAC_LENGTH_TOO_LONG] invalid alert (_ssl.c:1091)59```6061**Similar issues**: [encode/httpx#1424](https://github.com/encode/httpx/issues/1424).6263**Resolution**: HTTPX does not properly support HTTPS proxies at this time. If that's something you're interested in having, please see [encode/httpx#1434](https://github.com/encode/httpx/issues/1434) and consider lending a hand there.