rod icon indicating copy to clipboard operation
rod copied to clipboard

Proxy auth dialog handler is not working in another tab

Open itzngga opened this issue 1 year ago • 5 comments

Rod Version: v0.114.5

The code to demonstrate your question

func main () {
    launcher := launcher.New().
        Set(flags.ProxyServer, "proxy.example.com:8080").
        Launch()

    browserUrl, err := launcher.Launch()
    if err != nil {
    panic(err)
    }
    
    browser = rod.New().ControlURL(browserUrl).MustConnect()
    go browser.MustHandleAuth("test", "howto123")()
 }

What you got

Proxy auth dialog handler is not working in another tab

What you expect to see

The proxy auth connected in another tabs.

What have you tried to solve the question

Run the proxy handler goroutine with same opened tabs

Additional

Tangkapan Layar 2023-12-18 pukul 11 45 34 AM

the first tab was successfuly authenticated, except the another tab

itzngga avatar Dec 18 '23 04:12 itzngga

Please fix the format of your markdown:

33 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## Additional"]
34:1 MD033/no-inline-html Inline HTML [Element: img]

generated by check-issue

github-actions[bot] avatar Dec 18 '23 04:12 github-actions[bot]

you need two handlers, like this:

go browser.MustHandleAuth("test", "howto123")()
go browser.MustHandleAuth("test", "howto123")()

Read the doc, each event listener only waits for one single event, not all the events:

https://go-rod.github.io/#/events/README

ysmood avatar Dec 18 '23 09:12 ysmood

@ysmood it will panic, even the first tab was connected to proxy

panic: {-32000 Invalid state for continueInterceptedRequest } 

itzngga avatar Dec 18 '23 09:12 itzngga

yes, you have to use EachEvent to handle it, read the source code of HandleAuth

ysmood avatar Dec 18 '23 14:12 ysmood

following code is worked

  1. create page
  2. auth handle
browser.Page(proto.TargetCreateTarget{})
go p.browser.MustHandleAuth(username, password)()

xujinzheng avatar Mar 12 '24 09:03 xujinzheng