Unable to setup Proxy via HttpClientFactory
See original GitHub issuepublic class ProxyHttpClientFactory : HttpClientFactory
{
private string _proxyUrl;
public ProxyHttpClientFactory(string proxyUrl)
{
_proxyUrl = proxyUrl;
}
protected override HttpMessageHandler CreateHandler(CreateHttpClientArgs args)
{
var proxy = new WebProxy(_proxyUrl, true) { UseDefaultCredentials = true };
return new HttpClientHandler { UseProxy = true, Proxy = proxy};
}
}
...
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Automation App",
HttpClientFactory = new ProxyHttpClientFactory("http://192.168.30.99:8230")
});
I got a System.Net.Sockets.SocketException 10060 error.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14
Top Results From Across the Web
How to configure web proxy for HttpClient created directly ...
var httpClientFactory = services.GetService<IHttpClientFactory>(); var client = httpClientFactory.CreateClient(NamedHttpClients.ProxiedClient);.
Read more >How to configure web proxy for HttpClient created directly via ...
You can do something like this: private HttpClient ClientFactory() { var proxiedHttpClientHandler = new HttpClientHandler(){ UseProxy = true}; ...
Read more >Make HTTP requests using IHttpClientFactory in ASP.NET ...
Supports registration and chaining of multiple handlers to build an outgoing request middleware pipeline. Each of these handlers is able to ...
Read more >HttpClient Web Proxy Authentication - Forty Years of Code
A short article documenting proxy auth configuration. ... Proxy-Aware Handler; Register Http Client Factory; Using Http Client Factory ...
Read more >C# – How to configure web proxy for HttpClient created ...
Using the named client approach I'll use a constant to hold the client name. ... var httpClientFactory = services.GetService<IHttpClientFactory>(); var client = ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, that’s good to know. I wonder whether the auth part isn’t using the same HttpClientFactory… assigning to Chris to see if he knows more.
@djl394922860: There’s an example in https://github.com/googleapis/google-api-dotnet-client/issues/1537 that might help you.