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

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


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.


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.

Note You need to log in before you can comment on or make changes to this bug.