Open regnull opened 1 year ago
I found the same problem and got the solution from #399 and #567
You should set the DisableKeepAlives
as true
to make sure that the ProxyFunc is called on every request.
c.WithTransport(&http.Transport{
DisableKeepAlives: true,
})
I'm using an array of HTTP proxies and setting up the collector as described in the example:
However, I've noticed that only the first proxy is getting used. I've verified this by putting a breakpoint roundRobinSwitcher getProxy() function - it is called only once.
I've traced the problem here: https://cs.opensource.google/go/go/+/refs/tags/go1.19.3:src/net/http/transport.go;l=539
On the first pass, it doesn't go into the body of the IF, proceeds and eventually hits the GetProxy function. On the second pass, it gets the alternativeRoundTripper, goes into the IF, and returns, which means it doesn't call GetProxy function again.
Unfortunately, at this point I exceeded the limits of my knowledge and didn't research further. Perhaps someone on the team knows what is this about.
Great library, btw, thanks for your work!