influxdb-csharp icon indicating copy to clipboard operation
influxdb-csharp copied to clipboard

DNS does not update

Open bladefist opened this issue 4 years ago • 5 comments

Pretty simple report, if you use collector.example.com and you change that dns to point to another IP, the collector will not update until you cycle the app.

bladefist avatar Jun 08 '20 18:06 bladefist

@bladefist thanks for the issue. In other client libs you've used, is this option configurable or always on?

russorat avatar Jun 26 '20 21:06 russorat

I'm not sure as I would never cheat on this repository. I will say this is an issue that has come up before when using HttpClient (I assume this repo uses it). There are some easy fixes. If you're using a singleton it can be re-instated periodically. There are other solutions but I will admit I'm not an expert on it. thanks!

bladefist avatar Jun 26 '20 21:06 bladefist

Hi @bladefist,

I've been investigate how to fix it and it is a little bit complicated than it looks like. As you assume we are using a singleton: https://github.com/influxdata/influxdb-csharp/blob/fe041d744b39766475d2f3cf6300d76dfbe10b30/src/InfluxDB.LineProtocol/Client/LineProtocolClient.cs#L36 so re-instated periodically is possible but it seems to me a too tricky 😄.

The next option is use a ServicePoint.ConnectionLeaseTimeout but it looks that it isn't supported on all platforms.

  • https://docs.microsoft.com/en-us/dotnet/api/system.net.servicepoint.connectionleasetimeout?redirectedfrom=MSDN&view=netstandard-2.0
  • https://github.com/dotnet/standard/issues/642
  • http://byterot.blogspot.com/2016/07/singleton-httpclient-dns.html

Regards

bednar avatar Jul 03 '20 07:07 bednar

Starting from .NET Core 2.1 its possible to use IHttpClientFactory to handle the creation and recycling of the HttpClient/HttpMessageHandler, solving the DNS issue. An issue is that its coupled with Microsoft.Extensions.DependencyInjection.

sgtfrankieboy avatar Jul 03 '20 18:07 sgtfrankieboy

Any updates on this issue? We ran into this exact problem on my team yesterday and it bit us pretty hard. We're using v1.1.0.

wbaldoumas avatar Mar 04 '21 16:03 wbaldoumas