Skip to content

Commit a64f32b

Browse files
authored
Add note on connection timeout being larger than specified. Fix #5773
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.
1 parent a25fde6 commit a64f32b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

docs/user/advanced.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,4 +1122,12 @@ coffee.
11221122

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

1125+
.. note:: The connect timeout applies to each connection attempt to an IP address.
1126+
If multiple addresses exist for a domain name, the underlying ``urllib3`` will
1127+
try each address sequentially until one successfully connects.
1128+
This may lead to an effective total connection timeout *multiple* times longer
1129+
than the specified time, e.g. an unresponsive server having both IPv4 and IPv6
1130+
addresses will have its perceived timeout *doubled*, so take that into account
1131+
when setting the connection timeout.
1132+
11251133
.. _`connect()`: https://linux.die.net/man/2/connect

0 commit comments

Comments
 (0)