Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindUnusedPort #412

Closed
rioka opened this issue Jul 13, 2022 · 1 comment
Closed

FindUnusedPort #412

rioka opened this issue Jul 13, 2022 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@rioka
Copy link

rioka commented Jul 13, 2022

I occasionally get an error when I run tests, because the port that is selected is not actually free...

When debugging, I can see the problem is likely in MessagingProvider.FindUnusedPort: from what I can see, established connections are not excluded from the list, and eventually the service tried to bind to a non-free port.

            ICollection<int> used = IPGlobalProperties.GetIPGlobalProperties()
                                                      .GetActiveTcpListeners()
                                                      .Select(l => l.Port)
                                                      .ToList();

In my case, another application is using port 49152 (ie MinimumPort in the code), and the status of the connection is ESTABLISHED, so it is erroneously not included in the list of used ports I guess.

image

@adamrodger adamrodger added the bug Indicates an unexpected problem or unintended behavior label Jul 13, 2022
@adamrodger adamrodger added this to the 4.1.1 milestone Jul 13, 2022
@adamrodger
Copy link
Contributor

Yeah that needs GetActiveTcpConnections adding as well as listeners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants