Replies: 2 comments
|
Hello! It's already possible: SeleniumBase lets you spin up a local proxy server with SOCKS5 & auth in one console/terminal window, and then you can connect to it without auth in a separate console/terminal window. Instructions for that: Open two windows.
|
|
One constraint worth baking in, from our own experience with an intermediary proxy layer (not from SeleniumBase): a local relay sitting between browser and upstream must be timeout- and buffering-transparent. We ran long-polling behind a gateway and it broke exactly this way — proxy_read_timeout had to be strictly larger than the app's wait timeout, and proxy_buffering had to be off. Otherwise the client's wait returned empty immediately and looked like "nobody is talking"; with buffering on, the relay holds the response until a buffer fills, which turns one held response into a stalled connection. For your SOCKS relay that means:
A ~5 min test that catches all of it: point the relay at an endpoint that holds the connection open N seconds, and confirm the client receives the body once, at ~N s — not instantly, not never. Then kill the upstream mid-hold: you want an error, not an empty 200. On Q3, I'd state the constraint as "the relay must be timeout-transparent" rather than a Python floor. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
SeleniumBase already handles authenticated HTTP/HTTPS proxies really well (the runtime
chrome-proxyextension built inproxy_helper.create_proxy_ext). But authenticated SOCKS5/SOCKS4 proxies can't work in Chrome/Edge at all:--proxy-server, andwebRequest.onAuthRequirednever fires for SOCKS, so the extension approach doesn't help either.So today
Driver(proxy="socks5://user:pass@host:1080")fails withERR_NO_SUPPORTED_PROXIES/ERR_EMPTY_RESPONSE. This comes up fairly often (e.g. #3832 and various discussions), because a lot of residential/mobile providers only hand out authenticated SOCKS5 endpoints.Proposal
When the configured proxy is an authenticated SOCKS proxy, SeleniumBase could transparently start a tiny local, no-auth HTTP relay that forwards through the upstream SOCKS proxy, and point the browser at
127.0.0.1:<port>(cleaning it up ondriver.quit()). Everything else — including the existing HTTP-auth extension path and IP-authenticated SOCKS — stays exactly the same.The relay is ~150 lines of standard-library
asyncio(no new dependencies). I've already built and battle-tested this as a small standalone MIT library, and I'd be happy to contribute a trimmed, SOCKS-only version:https://github.com/SAKMZ/selenium-proxy-tools
Rough wire-in:
On Windows the relay uses
SelectorEventLoopso shutdown stays clean, and it does remote DNS (no DNS leaks).A few questions before I open a PR
proxy_helper.py, or add a newproxy_relay.py?Happy to open a PR along these lines (with a local SOCKS5-auth test, no network needed) if it's of interest. Thanks for SeleniumBase! 🙌
All reactions