docker-selenium icon indicating copy to clipboard operation
docker-selenium copied to clipboard

[πŸ› Bug]: Unable to use socks5 proxy

Open testcp98 opened this issue 1 year ago β€’ 6 comments

What happened?

opt_einsum = webdriver.ChromeOptions() opt_einsum.set_capability('browserVersion', '127.0') proxy = "xxx:x" opt_einsum.add_argument(f'--proxy-server=socks5://{proxy}') opt_einsum.add_argument(f'--proxy-auth=xxx:xxx') print(opt_einsum)

image

Command used to start Selenium Grid with Docker (or Kubernetes)

opt_einsum = webdriver.ChromeOptions()
    opt_einsum.set_capability('browserVersion', '127.0')
    proxy = "xxx:x"
    opt_einsum.add_argument(f'--proxy-server=socks5://{proxy}')
    opt_einsum.add_argument(f'--proxy-auth=xxx:xxx')
    print(opt_einsum)

Relevant log output

Traceback (most recent call last):
  File "/Users/chenp/Library/Application Support/JetBrains/IntelliJIdea2022.3/plugins/python/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/chenp/Library/Application Support/JetBrains/IntelliJIdea2022.3/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/chenp/btcweb/cf/selenium_get.py", line 35, in <module>
    session.get("https://api.ipify.org/")
  File "/opt/homebrew/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in get
    self.execute(Command.GET, {"url": url})
  File "/opt/homebrew/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/opt/homebrew/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_SOCKS_CONNECTION_FAILED
  (Session info: chrome=127.0.6533.119)
Stacktrace:
#0 0x56179ac936ca <unknown>
#1 0x56179a964600 <unknown>
#2 0x56179a95c631 <unknown>
#3 0x56179a94c839 <unknown>
#4 0x56179a94e5c4 <unknown>
#5 0x56179a94cb05 <unknown>
#6 0x56179a94c35f <unknown>
#7 0x56179a94c252 <unknown>
#8 0x56179a94a56c <unknown>
#9 0x56179a94a8ea <unknown>
#10 0x56179a966f21 <unknown>
#11 0x56179a9f5b45 <unknown>
#12 0x56179a9d68a2 <unknown>
#13 0x56179a9f504a <unknown>
#14 0x56179a9d6643 <unknown>
#15 0x56179a9a6d31 <unknown>
#16 0x56179a9a779e <unknown>
#17 0x56179ac5b25b <unknown>
#18 0x56179ac5f1f2 <unknown>
#19 0x56179ac48615 <unknown>
#20 0x56179ac5fd82 <unknown>
#21 0x56179ac2d25f <unknown>
#22 0x56179ac82e68 <unknown>
#23 0x56179ac83040 <unknown>
#24 0x56179ac9249c <unknown>
#25 0x7f8d74c3aa94 <unknown>

Operating System

mac

Docker Selenium version (image tag)

selenium/node-chrome:4.23.1-20240820

Selenium Grid chart version (chart version)

No response

testcp98 avatar Aug 28 '24 06:08 testcp98

@Char-Cp, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Aug 28 '24 06:08 github-actions[bot]

@diemol, Do you think this issue and also this https://github.com/SeleniumHQ/selenium/issues/14434 Which relates to the issue of a few capabilities getting filtered in the session response?

VietND96 avatar Aug 28 '24 09:08 VietND96

Those don't get filtered. They are part of ChromeOptions.

diemol avatar Aug 28 '24 09:08 diemol

@Char-Cp, instead of setting args from binding, can you try to use feat in docker-selenium to add args to browser directly via env vars - https://github.com/SeleniumHQ/docker-selenium?tab=readme-ov-file#se_browser_args_-add-arguments-for-launching-browser For example, adding these env vars and confirm

- SE_BROWSER_ARGS_PROXY_SERVER=socks5://your.proxy.ip.addr
- SE_BROWSER_ARGS_PROXY_AUTH=username:password

VietND96 avatar Aug 28 '24 09:08 VietND96

@VietND96 ,The image I used is selenium/node-chrome:4.23.1-20240820. I tried it according to your method, but it didn't work.

testcp98 avatar Aug 28 '24 10:08 testcp98

@VietND96 I tried the following methods. None of them can achieve proxy -e SE_BROWSER_ARGS_PROXY_SERVER=socks5://ip:port -e SE_BROWSER_ARGS_PROXY_AUTH=user:password -e SE_BROWSER_ARGS_PROXY_SERVER=socks5://user:password@ip:port

testcp98 avatar Sep 02 '24 05:09 testcp98