Closed CodingWithRoyal closed 3 years ago
Hi, please provide more info about what exactly you have tried and what you expected to happen.
Actually I resolved it! I was using socks:// instead socks5://
This is the correct argument to use socks5 proxy with CEF
--proxy-server=socks5://127.0.0.1:4799
glad to hear it!
Can you guide me how to set proxy because when I do setPreference it give me true and set proxy but still proxy didn't work and also the function onAuthCredentialsRequired not called.
@umairzahid508
With Chrome options
options = { 'proxy': { 'http': 'socks5://user:pass@192.168.10.100:8888', 'https': 'socks5://user:pass@192.168.10.100:8888', 'no_proxy': 'localhost,127.0.0.1' } } driver = webdriver.Chrome(seleniumwire_options=options)
You can also use command line argv for this. Here's full list of argv
@CodingWithRoyal I want to apply the proxy at runtime and after searching a lot I found out that if I use commandLine argument then I cannot change the proxy at runtime so try to achieve it through setPreference but that didn't work for me I will attach the code below for clear understanding .
`
// from CEFLifeSpanHandler
func onAfterCreated(browser: CEFBrowser) {
_browserList.append(browser)
var proxy = String()
var port = String()
proxy = "proxy"
port = "port"
let cx = browser.host?.requestContext
let refs = cx?.allPreferences(includeDefaults: true)
let dic = refs?.dictionary(for: "proxy")
let new_CEFVALUE = CEFValue.init()
let new_CEFVALUE2 = CEFValue.init()
new_CEFVALUE?.setString("fixed_servers")
new_CEFVALUE2?.setString("" + proxy + ":" + port + "")
dic?.set(new_CEFVALUE!, for: "mode")
dic?.set(new_CEFVALUE2!, for: "server")
let new_CEFVALUE3 = CEFValue.init()
new_CEFVALUE3?.setDictionary(dic!)
browser.host?.requestContext!.setPreference(new_CEFVALUE3, for: "proxy")
}`
Above the code run when I hit the URL and setPreference give me true but after that onAuthCredentialsRequired func not called and also proxy didn't work.
@CodingWithRoyal @lvsti Can you help me to set runtime proxy in setPreference?
I searched a lot on CEF forum but didn't work anything for me but I noticed one thing that everyone do proxy setPreference work in CEF_UIThreadFactory as you see in below image but I didn't find this method in your repo so can you help me doing this ?
Thanks.
I am trying to configure SOCKS proxy as CommandLineArg but doesn't work
cmdLine?.appendArgument("--proxy-server=socks://127.0.0.1:4799")