-
Notifications
You must be signed in to change notification settings - Fork 5k
HttpListener always fails with error 32 on ports 50000-50059 #115088
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
Comments
Tagging subscribers to this area: @dotnet/ncl |
Http listener is a simple wrapper on WinHTTP and exists solely for compatibility. There's nothing actionable at .NET side. HttpListener is outdated today and generally not recommended. See #63941 (comment) . |
Have you made sure that it is not the system on which you try to connect port 50000? |
I am currently using ASP.NET Core for a built-in HTTP server to allow communication between my application and browsers, but I've been trying to move away from ASP.NET Core, because explaining to regular users the difference between .NET Runtime and ASP.NET Core Runtime is too complicated. The .NET download page doesn't include installers for ASP.NET Core Runtime for macOS, only binaries. When users try to run the application without ASP.NET Core Runtime installed, the error directs them to another download page, where macOS doesn't have a download for the ASP.NET Core Runtime at all. I'm not sure how regular users are supposed to figure out how to run .NET applications that depend on ASP.NET Core.
It's possible, but from what I discovered, it's only .NET's Windows-specific implementation of If the managed implementation of |
You can use a self-contained deployment so that users of your application don't have to install the runtime separately. |
I already use self-contained deployment, but not for every single combination of OS and architecture. It makes sense for me to release a version of my app that can work on any OS/arch if the user installs the runtime, but the dependency on ASP.NET is complicating that so much, that for a long time I've been looking for a solution that lets me get rid of the ASP.NET dependency. I actually found the Sisk HTTP server library, through which I discovered |
#71518 (comment) may be relevant (see comment about port exclusion range) |
Interesting, thanks. It's still strange to me why Kestrel can bind to these ports while HttpListener/WinHTTP cannot. I noticed that Resource Monitor shows Kestrel's sockets as owned by the application itself, while HttpListener's sockets are owned by 'System'. Maybe that's related. I already try to avoid used ports by looping through |
Description
Hi, I'm trying to have an
HttpListener
listen on127.0.0.1:50000
, but it always fails with error 32, saying that the process does not have access to a file because it's being used by another process.However, there is no process listening on port 50000:
Furthermore, there is no issue at all with the same port, if I use ASP.NET Core and Kestrel instead:
I tried all ports between 20000 and 65535, and the errors mostly correspond to ports that are actually being listened on by other programs, but then there's just a random(?) range of ports 50000-50059 that
HttpListener
always fails to listen on, despite no other program listening on them.Reproduction Steps
Expected behavior
Call
Start
with no exceptions.Actual behavior
Regression?
No response
Known Workarounds
I tried running the test under WSL1, and there were no issues with ports 50000-50059.
I see that
HttpListener
has a separate implementation for Windows, and a managed implementation for other operating systems, so it seems the issue is only with the Windows implementation.A workaround could be to use the managed implementation for Windows, but I don't know if that's possible without rebuilding the whole .NET runtime. https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.HttpListener/src/System.Net.HttpListener.csproj
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: