Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

c# - HTTP 503 Service is unavailable when trying to browse signalr/hubs

I have a windows hosted SignalR hub created in VS2012:

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);
        }
    }

I have deployed this windows service on 3 different PCs, it works fine on two PCs, but on the other, I get HTTP 503 Service is unavailable when I try to browse http://localhost:8080/signalr/hubs

No exception thrown when the code is executed on all 3 PCs.

I have checked IIS's features in add/remove windows features, they're all the same.

What am I missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was able to reproduce this locally with the following setup:

  1. Use NetSh.exe or similar tool to reserve http://localhost:8080/
  2. Call WebApp.Start<Startup>("http://*:8080")
  3. Browse to http://localhost:8080/

What happens is that Http.Sys accepts the incoming request, examines the host header, decides that there is a reservation for localhost:8080, but realizes that no application is listening to localhost:8080, only *:8080. Http.Sys then returns the 503.

Solutions:

  1. Try WebApp.Start<Startup>("http://+:8080")
  2. Remove the Http.Sys/NetSh registration

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...