-
-
Notifications
You must be signed in to change notification settings - Fork 748
Open
Labels
Description
- Version: 0.4.0
- Target: Windows, dotnet 10.0
Steps to Reproduce:
- When I minimized the startup console application, the following error occurred:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: listen EACCES: permission denied 127.0.0.1:8000
at Server.setupListenHandle [as listen2] (node:net:1881:21)
at listenlnCluster (node:net:1946:12)
at GetAddrlnfoReqWrap.doListen [as callback] (node:net:2116:7)
at GetAddrlnfoReqWrap.onlookup [as oncomplete] (node:dns:111:8)- I used the Windows netsh command to obtain a range of ports that, for reasons unknown, have been excluded by Windows, resulting in these ports being unavailable for use:
- The GetActiveTcpListeners() method within GetFreePort() cannot retrieve the aforementioned excluded ports.
// PortHelper.cs
public static int GetFreePort(int? defaultPost)
{
var listeners = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners().Select(e => e.Port).ToList();
int port = defaultPost ?? 8000;
while (true)
{
if (!listeners.Contains(port))
{
return port;
}
port += 2;
}
}