【问题标题】:HTTP 503 Service is unavailable when trying to browse signalr/hubs尝试浏览信号器/集线器时 HTTP 503 服务不可用
【发布时间】:2014-04-13 03:49:37
【问题描述】:

我有一个在 VS2012 中创建的 Windows 托管 SignalR 集线器:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCors(CorsOptions.AllowAll);
        app.MapSignalR();
    }
}

public static class SignalR
{
    public static void Start()
    {
        const string url = "http://*:8080";
        WebApp.Start<Startup>(url);
    }
}

 public class Broadcaster : Hub
    {

        public void SendDownloadResult(bool result, string device, string description, string connectionId, string task)
        {
            var context = GlobalHost.ConnectionManager.GetHubContext<Broadcaster>();
            context.Clients.Client(connectionId).sendDownloadResult(result, device, description, task);
        }
    }

我已经在 3 台不同的 PC 上部署了这个 windows 服务,它在两台 PC 上运行良好,但另一方面,当我尝试浏览 http://localhost:8080/signalr/hubs 时,我得到 HTTP 503 服务不可用

代码在所有 3 台 PC 上执行时均未抛出异常。

我在添加/删除windows功能中检查了IIS的功能,它们都是一样的。

我错过了什么?

【问题讨论】:

    标签: c# .net windows-services signalr


    【解决方案1】:

    我能够通过以下设置在本地重现此内容:

    1. 使用NetSh.exe或类似工具保留http://localhost:8080/
    2. 致电WebApp.Start&lt;Startup&gt;("http://*:8080")
    3. 浏览至http://localhost:8080/

    发生的情况是 Http.Sys 接受传入的请求,检查主机头,确定有 localhost:8080 的保留,但意识到没有应用程序正在侦听 localhost:8080,只有 *:8080。 Http.Sys 然后返回 503。

    解决方案:

    1. 试试WebApp.Start&lt;Startup&gt;("http://+:8080")
    2. 删除 Http.Sys/NetSh 注册

    【讨论】:

    【解决方案2】:

    我还意识到,在其中一台 PC 中,端口 8080 正在使用中。

    更改端口

    const string url = "http://*:8080";
    

    const string url = "http://*:8088";
    

    解决了问题

    【讨论】:

    • 不,他的意思是* When the host element of a UrlPrefix consists of a single plus sign (+), the UrlPrefix matches all possible host names in the context of its scheme, port and relativeURI elements, and falls into the strong wildcard category. When an asterisk (*) appears as the host element, then the UrlPrefix falls into the weak wildcard category. This kind of UrlPrefix matches any host name associated with the specified scheme, port and relativeURI that has not already been matched by a strong-wildcard
    【解决方案3】:

    我也有同样的问题。我通过改变来纠正它

     const string url = "http://*:8080";
    

     const string url = "http://+:8080"; // * replaced by +
    

    【讨论】:

      猜你喜欢
      • 2014-10-26
      • 2013-10-28
      • 2019-10-30
      • 2021-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      相关资源
      最近更新 更多