Bug 58714 - HttpListener does not support "+" as special host for IPAddress.Any
Summary: HttpListener does not support "+" as special host for IPAddress.Any
Status: RESOLVED NORESPONSE
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-11 05:25 UTC by Retroposter
Modified: 2018-03-13 11:07 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Retroposter 2017-08-11 05:25:49 UTC
I am using NancyFx as web host on both Windows and Linux (on Windows I am using .NET Framework 4.6.1 and on Linux I am using Mono 4.2). But when I start the host, it spends 10 seconds more on Linux.

Root Cause:
Mono HttpListener (accurately is System.Net.EndPointManager) does not support "+" as the special host for IPAddress.Any. As result, Mono hangs on "Dns.GetHostByName("+");" about 10 seconds and then failed (means mono determines + is not dns) if I do following.

	HttpListener.Prefixes.Add("http://+:3580/");
	HttpListener.Start()

According to https://msdn.microsoft.com/zh-cn/library/system.net.httplistenerprefixcollection.add.aspx, both "*" and "+" should be supported as special host for IPAddress.Any.
Please refer to .NET Core implemenation in System.Net.HttpEndPointManager

Related bug: 31491
Comment 1 Marek Safar 2017-09-08 23:48:19 UTC
Thank you for your report!

It appears you are running a very old version of Mono. Could you please try to update to any recent version and try to reproduce the issue again.

If the issue still persists please include the version information and change the bug status to NEW.
Comment 2 Retroposter 2017-09-10 14:32:23 UTC
Yes, I am using Mono 4.2, an older version. It is not easy for me to upgrade our Mono version but I will find a way to check with version 5.7.

But I believe the issue still persists since there is no "+" check in the latest System.Net.EndPointManager.GetEPListener:

1.    IPAddress addr;
2.    if (host == "*")
3.        addr = IPAddress.Any;
4.    else if (IPAddress.TryParse(host, out addr) == false){
5.        try {
6.            IPHostEntry iphost = Dns.GetHostByName(host);
7.            if (iphost != null)
8.                addr = iphost.AddressList[0];
9.            else
10.                addr = IPAddress.Any;
        } catch {
            addr = IPAddress.Any;
        } 
     }

Diff it with .DotNet Core System.Net.HttpEndPointManager please.
Comment 3 Marek Safar 2018-03-13 11:07:32 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!