Hi,
according to several resources (link 1, link 2) there should be a single HttpClient instance per application instance, shared across all the threads, reused for every http call.
While this seems to be possible to achieve with bare HttpClient, I don’t really know what is the correct usage when it comes to JsonHttpClient. According to this response, and looking through the code, it looks like there is a single instance of HttpClient per JsonHttpClient, which is disposed when JsonHttpClient is disposed.
Does this imply there should be a single, re-used instance of JsonHttpClient too?
How to deal with “per-context” properties like UserName / Password / BearerToken etc in such case?
Technically, I think it is possible to manage single instance of HttpClient manually, then assign it to newly created JsonHttpClient. But that would require us to un-tie HttpClient instance before disposing JsonHttpClient, othwerwise it’d get disposed too.
This looks like an extremely fragile and error-prone solution.