NLog.Targets.HTTP
NLog.Targets.HTTP copied to clipboard
Port Exhaustion on .NET 5
Using this target on .NET 5 appears to eat up ports. We are hitting the 128 port limit out on Azure App Service when we have this target turned on. It's not immediately obvious to me how we can mitigate this, so wanted to start the conversation.
Acknowledged. Can you provide your configuration setup without the sensitive parts, please?
<target name='TargetName'
type='HTTP'
URL='urlhere'
Method='POST'
BatchSize='1'
MaxQueueSize='2147483647'
IgnoreSslErrors='true'
FlushBeforeShutdown='true'
ContentType='application/json'
Accept='application/json'
DefaultConnectionLimit='2'
Expect100Continue='false'
UseNagleAlgorithm='true'
ConnectTimeout='30000'
InMemoryCompression='true'
>
</target>
We are also seeing a similar issue with high port utilization and occasional exhaustion in Azure App Service with essentially the same configuration. We are running on .NET Core 3.1 though. Currently have deployed with version 1.0.10 of NLog.Targets.HTTP as there were unresolved issues at the last update with newer versions (since resolved).
Acknowledged. Rough week at work. Will look into it over the weekend.
Hey @DarekDan any update here? No worries if you’ve been busy.
Hey @DarekDan any update on this?
Hey,
I ran into the same problem last weekend with an automated service (.NET6)
I'm not sure, but i assume, that there is a chance, that the ResetHttpClientIfNeeded Method spawns rapidly SocketHttpHandler and this is causing the issue.
A simple _httpClient?.Dispose()
could help
Also HTTP should override the Dispose to at least call _httpClient.Dispose()
Even if it does not fix the issue, it's at least a good practice 😄
Created a PR for this: https://github.com/DarekDan/NLog.Targets.HTTP/pull/43
Just looked again at it. Maybe this is the problem here. This should be quite easy to implement. But i don't know, if the owner want this kind of solution (mainly cause of a new depandency, Microsoft.Extensions.Http ).