Microsoft.Extensions.Diagnostics.Probes.KubernetesProbesExtensions.AddKubernetesProbes() fails with SocketException "Only one usage of each socket address (protocol/network address/port) is normally permitted" #5082
Labels
bug
This issue describes a behavior which is not expected - a bug.
Description
When application is started with AddKubernetesProbes() extension option we get
SocketException Only one usage of each socket address (protocol/network address/port) is normally permitted
errors in the console.We were expecting that when AddKubernetesProbes() is called with no options, the default ports in https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/KubernetesProbesOptions.cs (2305, 2306, 2307) would be used. However when we check netstat, only 2305 port is bound and 2306/2307 ports are not bound.
This is occurring on dotnet 8.0.202 and on Microsoft.Extensions.Diagnostics.Probes version 8.0.0-rtm.23558.11 and 9.0.0-preview.2.24157.4 (didn't try other versions).
This only occurs on the base AddKubernetesProbes function without additional parameters.
When using the overloaded method and specifying the ports is used, the errors do not occur:
Reproduction Steps
dotnet new webapi --name KubernetesProbesBugReport
<PackageReference Include="Microsoft.Extensions.Diagnostics.Probes" Version="9.0.0-preview.2.24157.4"/>
dotnet run
Expected behavior
There should not be any SocketException in the console when AddKubernetesProbes used and that default ports in KubernetesProbesOptions would be used.
Actual behavior
SocketExceptions are observed in the console when AddKubernetesProbes() is used.
Regression?
No response
Known Workarounds
Using one of the AddKubernetesProbes overloaded method and specifying the ports works:
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: