Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

signalr - Self hosted OWIN and urlacl

I've created a self hosted Nancy/SignalR application self-hosted in OWIN using Microsoft.Owin.Host.HttpListener and Microsoft.Owin.Hosting

Things work perfectly fine locally but as soon as I try to use anything but localhost to access the app I get a HTTP Error 503. The service is unavailable error. I can't even access the app using 127.0.0.1 or the machine name.

I've tried adding the port to urlacl using

http add urlacl http://*:8989/ user=EVERYONE but doesn't seem to do anything.

here are the OWIN start options that I've tried,

        var options = new StartOptions
        {
            Url = "127.0.0.1",
            App = GetType().AssemblyQualifiedName,
            Port = _configFileProvider.Port
        };

    var options = new StartOptions
        {
            App = GetType().AssemblyQualifiedName,
            Port = _configFileProvider.Port
        };

here is the source code for the file that starts and stops the server https://github.com/NzbDrone/NzbDrone/blob/vnext/NzbDrone/Owin/OwinHostController.cs

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

so it turns out you need to pass in a url into StartOptions in the same format as the urlacl.

Changing the start options to the code below fixed the problem. now the app is accessible across the network.

  var options = new StartOptions("http://*:8989")
  {
      ServerFactory = "Microsoft.Owin.Host.HttpListener"
  };

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...