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

IPv6 System.Net.HttpListenerException (400): Invalid port in prefix. #34399

Open
maxthedread opened this issue Apr 1, 2020 · 3 comments
Open

Comments

@maxthedread
Copy link

dotnet --version
3.1.201

_httpListener.Prefixes.Add("http://[::1]:54321/meow/");

works fine on Windows but fails on linux-x64 (WSL, Ubuntu)

exception: System.Net.HttpListenerException (400): Invalid port in prefix.
at System.Net.HttpEndPointManager.AddPrefixInternal(String p, HttpListener listener)
at System.Net.HttpEndPointManager.AddListener(HttpListener listener)
at System.Net.HttpListener.Start()

Additionally the behavior in regards of IPv4 IPv6 on Windows and Linux is different. With the prefix:
http://localhost:54321/meow/

HttpListener binds both to IPv4 and IPv6 on Windows. But not on Linux.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Apr 1, 2020
@ghost
Copy link

ghost commented Apr 1, 2020

Area Owners

@dotnet/ncl

@davidsh
Copy link
Contributor

davidsh commented Apr 1, 2020

works fine on Windows but fails on linux-x64 (WSL, Ubuntu)

FYI, the implementation of HttpListener on Linux is substantially different than Windows. Windows uses the original .NET Framework (ported to .NET Core) implemented layered on top of http.sys. Linux uses a separate implementation originally from Mono.

@karelz karelz added bug and removed untriaged New issue has not been triaged by the area owner labels May 14, 2020
@karelz karelz added this to the Future milestone May 14, 2020
@josemoliver
Copy link

Similar issue here, works fine in Windows 11 (.net 6.0.401) but fails in Raspberry Pi OS (linux-arm 6.0.401)
System.Net.HttpListenerException (400): Invalid path.

listener.Prefixes.Add("http://*:"+port+"/"+path);

https://github.com/josemoliver/WeatherServer/blob/main/Program.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants