503 Error when using NancyFx with Owin

萝らか妹 提交于 2019-12-14 03:53:48

问题


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:


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.



来源:https://stackoverflow.com/questions/42970507/503-error-when-using-nancyfx-with-owin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!