Rotating proxy kept returning one IP because requests.Session reused a single connection
A developer found that a rotating proxy kept showing the same IP address, while curl loops through the same gateway changed IPs each time. The cause was connection reuse: requests.Session and multiple URLs in one curl command send all requests over one connection, and for HTTPS that connection is an opaque tunnel the gateway cannot re-route. Fixes include making a fresh connection per request, sending a Connection: close header, or using a provider's sticky session when a single IP is needed. The author explained that an HTTP proxy only sees a CONNECT request for HTTPS traffic, so it can rotate only when a new tunnel is opened. They tested this on a Mac with a custom local proxy that simulates rotation, using documentation IP addresses.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in