-1

did everything like here (Python selenium chromedirver( headerless) use proxies( IPV6 ) with Authentication) but the error ERR_TUNNEL_CONNECTION_FAILED pops up tried all the options, but nothing helps. my code:

manifest_json = """
{
    "version": "1.0.0",
    "manifest_version": 2,
    "name": "Chrome Proxy",
    "permissions": [
        "proxy",
        "tabs",
        "unlimitedStorage",
        "storage",
        "<all_urls>",
        "webRequest",
        "webRequestBlocking"
    ],
    "background": {
        "scripts": ["background.js"]
    },
    "minimum_chrome_version":"76.0.0"
}
"""

background_js = """
var config = {
        mode: "fixed_servers",
        rules: {
        singleProxy: {
            scheme: "http",
            host: "%s",
            port: parseInt(%s)
        },
        bypassList: ["localhost"]
        }
    };
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
    return {
        authCredentials: {
            username: "%s",
            password: "%s"
        }
    };
}
chrome.webRequest.onAuthRequired.addListener(
            callbackFn,
            {urls: ["<all_urls>"]},
            ['blocking']
);
""" % (PROXY_HOST, PROXY_PORT, PROXY_USER, PROXY_PASS)


def get_chromedriver(use_proxy=False, user_agent=None):
    chrome_options = webdriver.ChromeOptions()

    if use_proxy:
        plugin_file = 'proxy_auth_plugin.zip'

        with zipfile.ZipFile(plugin_file, 'w') as zp:
            zp.writestr('manifest.json', manifest_json)
            zp.writestr('background.js', background_js)

        chrome_options.add_extension(plugin_file)

    if user_agent:
        chrome_options.add_argument(f'--user-agent={user_agent}')

    s = Service(
        executable_path='chromedriver.exe'
    )
    driver = webdriver.Chrome(
        service=s,
        options=chrome_options
    )

    return driver


def main():
    driver = get_chromedriver(use_proxy=True,
                              user_agent='Mo...')
    driver.get('https://test-ipv6.com ')
    sleep(10)
    driver.close()
    driver.quit()


if __name__ == '__main__':
    main()

did everything like here (Python selenium chromedirver( headerless) use proxies( IPV6 ) with Authentication) but the error ERR_TUNNEL_CONNECTION_FAILED pops up tried all the options, but nothing helps. thanks

Artik gnom
  • 25
  • 1
  • 7
  • Please provide enough code so others can better understand or reproduce the problem. – Akzy Jan 26 '23 at 05:46

1 Answers1

1

I see 2 possible issues here:

  • Your proxy isn't valid//doesn't work
  • in background_js, try using instead:
...
...
singleProxy: {
            scheme: "http",
            host: "%s",
            port: %s
        },
...
...
kaliiiiiiiii
  • 925
  • 1
  • 2
  • 21