Custom HttpClientFactory doesnot work after upgrade to new version
See original GitHub issueI got a “Unable to read data from the transport connection” error with the follow codes, but it works with the old version.
thank you.
var proxy = "http://192.168.1.200:8080";
var client = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Gbackuper Directory Helper Class",
HttpClientFactory = new ProxyHttpClientFactory(proxy),
});
var orgunitsRequest = client.Orgunits.List("my_customer");
orgunitsRequest.Type = OrgunitsResource.ListRequest.TypeEnum.All;
var orgs = await orgunitsRequest.ExecuteAsync(cancellationToken);
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 = false };
return new HttpClientHandler { UseProxy = true, Proxy = proxy};
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top Results From Across the Web
Make HTTP requests using IHttpClientFactory in ASP.NET ...
Learn about using the IHttpClientFactory interface to manage logical HttpClient instances in ASP.NET Core.
Read more >vb.net - unable to make httpclientfactory working from a . ...
I am just trying to implement HttpClientFactory in my . net 4.7. 2 Winforms app for a rest-api client.
Read more >Using HttpClientFactory in ASP.NET Core Applications
Let's learn how to use HttpClientFactory in .NET Core applications. Also, we will learn how to use Named and Typed client instances.
Read more >Make SOAP requests using IHttpClientFactory in .NET Core
I updated NuGet packages and all started working as it should! I hit it from JMeter with 5 threads (and 100 calls per...
Read more >You're using HttpClient wrong and it is destabilizing your ...
I've been using HttpClient wrong for years and it finally came back to bite me. My site was unstable and my clients furious,...
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
awesome, it works!!!
Okay, great. Will close this issue.