HttpSelfHostServer (System.Web.Http.SelfHost) fails to set up listener on IPv4 on specific computer

Viewed 17

I've a Windows application (.NET Framework 4.8) that uses HttpSelfHostServer to handle client request.

            string address = "0.0.0.0";
            int port = 8550;
            var route = "Test/1.0/{controller}";
            var baseAddress = new Uri(String.Format("http://{0}:{1}", address, port));
            var config = new HttpSelfHostConfiguration(baseAddress);
            config.Routes.MapHttpRoute($"Test_{port}", route, new { });
            var server = new HttpSelfHostServer(config);
            server.OpenAsync();
            servers.Add(server);

The application listens on all available network cards and has been working fine for many years. The problem is that I now have one computer where it doesn't work! The application have the same assamblies loaded, and is using Windows 10 with the latest updates.

On a computer where the application is working fine, netstat shows the following listeners; [enter image description here]

C:\Users\admincod>netstat -na | find "8550"
  TCP    0.0.0.0:8550           0.0.0.0:0              LISTENING
  TCP    [::]:8550              [::]:0                 LISTENING

But on the computer where it does not work it will only show the later post

  TCP    [::]:8550              [::]:0                 LISTENING

Have tried to reinstall network drivers and disable IPv6. I also tried to disable the firewall, but shouldn't be neccessary since it's only a listener?

Kind regards

Robert

1 Answers

It took a while but finally I found a solution to my problem.

Using netsh I discovered that there where nothing that listened on IPv4

C:\WINDOWS\system32>netsh http show iplisten

IP addresses present in the IP listen list:
-------------------------------------------

    ::

And the solution was to simple add a new record like

C:\WINDOWS\system32>netsh http add iplisten ipaddress=0.0.0.0

IP address successfully added
Related