question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to setup Proxy via HttpClientFactory

See original GitHub issue
public 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

1reaction
jskeetcommented, Jan 8, 2020

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.

0reactions
jskeetcommented, Apr 7, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found