# NEST: customize creation of HttpClient

**URL:** <https://discuss.elastic.co/t/nest-customize-creation-of-httpclient/256687>\
**Category:** Elasticsearch\
**Created:** [November 25, 2020, 4:29pm UTC](https://discuss.elastic.co/t/nest-customize-creation-of-httpclient/256687 "2020-11-25T16:29:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonsagara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonsagara/32/26170_2.png) [@jonsagara](https://discuss.elastic.co/u/jonsagara)\
**Post date:** [November 25, 2020, 4:29pm UTC](https://discuss.elastic.co/t/nest-customize-creation-of-httpclient/256687/1 "2020-11-25T16:29:57Z")

</div>

Hello,

There is a known issue with targeting `net5.0` on Azure App Service and trying to connect to Elasticsearch on a virtual machine connected to via an Azure VNet. The main ticket is here:

> <https://github.com/dotnet/runtime/issues/44686>
>
> I have an ASP.NET Core 3.1 application running in Azure App Service. It makes calls to Elasticsearch running on an Ubuntu...

The issue is essentially that .NET 5.0's `HttpClient` is trying to use IPv6 wherever it's supported. The .NET runtime's team has a suggested workaround where you force `HttpClient` to use IPv4:

> <https://github.com/dotnet/runtime/issues/44686#issuecomment-733797994>
>
> I have an ASP.NET Core 3.1 application running in Azure App Service. It makes calls to Elasticsearch running on an Ubuntu...

**Question:** is it possible to customize `NEST`'s creation of `HttpClient` instances to force it to use IPv4 sockets as described in the workaround above?

Thank you,

Jon

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 23, 2020, 4:30pm UTC](https://discuss.elastic.co/t/nest-customize-creation-of-httpclient/256687/2 "2020-12-23T16:30:01Z")

</div>

Closed on December 23, 2020, 4:30pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
