2
votes

I'm trying to use NancyFx in combination with SignalR. In order to host both, I'm using Microsoft Owin. But unfortunately I always get an 503 (Service unavailable), when trying to access the REST-API via PostMen (REST-Api Client extension for chromium browsers). So I extracted the main ingredients to a more simple program, that allows me to switch between Nancy Selfhost and Owin. When using Nancy SelfHost, everything works fine, but using Owin I still got a 503 error.

internal class Program {
    private const bool _USE_SELF_HOST = false;

    private static void Main(string[] args) {
        if (_USE_SELF_HOST) {
            var host = "http://localhost:7084";
            UseSelfHost(host);
        } else {
            var host = "http://localhost:7084";
            UsingWebApp(host);
        }
    }

    private static void UseSelfHost(string host) {
        var webhost = new NancyHost(new Uri(host));
        webhost.Start();

        Console.ReadLine();
        webhost.Stop();
    }

    private static void UsingWebApp(string host) {
        var nancyHost = WebApp.Start<Startup>(host);
        Console.WriteLine($"Nancy started at {host}");
        Console.ReadLine();
        nancyHost.Dispose();
    }

}

public class MainModule : NancyModule {
    public MainModule() {
        Get["/"] = x => "Hello world!";
    }
}

I checked:

  • netsh http show urlacl - I'm allowed to open this port
  • Visual Studio is running with Admin rights, besides this should not be needed.
1

1 Answers

3
votes

A colleague of mine found an error in my netsh configuration. I had two urlacls for the same tcp port:

Reservierte URL            : http://wks-user:7084/
    Benutzer: DOMAIN\user
        Abh▒ren: Yes
        Delegieren: No
        SDDL: D:(A;;GX;;;XXX)

Reservierte URL            : http://+:7084/
    Benutzer: DOMAIN\user
        Abh▒ren: Yes
        Delegieren: No
        SDDL: D:(A;;GX;;;XXX)

After removing the first entry via

netsh http delete urlacl http://wks-user:7084/

everything works as expected.