I am working on an ASP.NET Core 2.0 API, and my API needs to make calls to another, third-party, REST API to load and extract files, get file lists and status information. I will host the API on Azure and plan to deploy Blue-Green between my intermediate and production slots.
It seems that the general consensus regarding best practice is to configure the SingleClate HTTPClient instance through DI registration in Startup.cs -> ConfigureSerrvices to improve performance and avoid socket errors that may occur if I am new to establish an HTTPClient connection with each use using the Using statement. This is noted in the following links:
https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/
https://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx#Anchor_5
http://www.nimaara.com/2016/11/01/beware-of-the-net-httpclient/
But if I do this, then I may run into a problem when the Singleton instance does not see any DNS changes when I deploy Blue-Green in Azure. This is noted in the following links:
http://byterot.blogspot.co.uk/2016/07/singleton-httpclient-dns.html
https://github.com/dotnet/corefx/issues/11224
, HTTPClient, ConnectionLeaseTimeout ServicePoint , , DNS. RestClient nuget (Easy.Common by Nima), ConnectionLeaseTimeout, DNS.
, , ASP.NET Core 2.0 ServicePoint, ASP.Net Core 2.0.
- , HttpClient API ASP.NET Core 2.0, Azure? Blue-Green. , Using ?
, .
, , , , ConnectionLeaseTimeout - , , , . , , , Connection: Close , . . , . Flurl, .
ConnectionLeaseTimeout
Connection: Close
, , DNS . , , ( 100 ). HttpClient .
HttpClient
, . , , , DefaultRequestHeaders, , , . , . ( , 1000 , 1000 , .) , DNS- , Connection: Close HttpClient . , , , .
DefaultRequestHeaders
, , , HttpClient, ( ).
, , -, . HttpClient , , HttpClient, , -, HttpClient.
, , using HttpClient, . , .
using
Source: https://habr.com/ru/post/1691635/More articles:How to subtract inserted / removed headphones in javascript? - javascriptHow to replace each element of an array with a different array in Python? - pythonHow to convert values inside nested lists to sets? - pythonChange background color and name in MFC Control - winapiКак предотвратить обновление срока действия сеанса для определенного URL-адреса - pythonHow to call preventDefault () before a synthetic event is processed? - reactjsevent.preventDefault in asynchronous functions - javascriptProblems with e.preventDefault () - jqueryjava.util.Base64 decodes and then encodes, gives another line - javaSpark Sql UDF throws NullPointer when adding a filter to columns that use this UDF - scalaAll Articles