Skip to content

Commit

Permalink
Add note on connection timeout being larger than specified. Fix #5773
Browse files Browse the repository at this point in the history
On servers with multiple IPs, such as IPv4 and IPv6, `urllib3` tries each address sequentially until one successfully connects, using the specified timeout for _each_ attempt, leading to a total connection timeout that is a _multiple_ of the requested time.
  • Loading branch information
MestreLion authored Dec 13, 2023
1 parent a25fde6 commit a64f32b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/user/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1122,4 +1122,12 @@ coffee.

r = requests.get('https://github.com', timeout=None)

.. note:: The connect timeout applies to each connection attempt to an IP address.
If multiple addresses exist for a domain name, the underlying ``urllib3`` will
try each address sequentially until one successfully connects.
This may lead to an effective total connection timeout *multiple* times longer
than the specified time, e.g. an unresponsive server having both IPv4 and IPv6
addresses will have its perceived timeout *doubled*, so take that into account
when setting the connection timeout.

.. _`connect()`: https://linux.die.net/man/2/connect

0 comments on commit a64f32b

Please sign in to comment.