net/http: allow concurrent requests with different Transport proxy #31952
Comments
Can you show example code? |
i have add some example code @bradfitz |
Correct; you cannot set Transport.Proxy from two concurrent goroutines, just like how you can't set anything else concurrently from two concurrent goroutines. Your Transport.Proxy function should be set before any concurrent use and then it should consult its |
@windzhu0514 , Hi, buddy, I met exactly the same issue, I have a proxy pool, for each http request I will choose one proxy from the pool. With only one HttpClient, proxy is not concurrent safe. |
@sinylei the solution i found is writing youself Proxy select func and set transport.Proxy before before any concurrent use. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
there is one transport in my program
several goroutine send get request with same url
when one request return 403 , i change the proxy
What did you expect to see?
every goroutine can use it own proxy
it seems transport.Proxy is not safe for concurrent
What did you see instead?
the proxy in other goroutine request is also change
example code
i want each request use it's own proxy
The text was updated successfully, but these errors were encountered: