1

I have my SignalR Host in a simple Windows Service application.

protected override void OnStart(string[] args)
{
    const string url = "https://localhost:8080";

    AppDomain.CurrentDomain.Load(typeof(MyHub).Assembly.FullName);

    using (WebApp.Start<Startup>(url))
    {
        Log(string.Format("Device Hub started on {0}", url));
    }
}

Where MyHub is the name of my Hub class in a referenced console project and Startup is just

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

SignalR seems to start, but I keep getting a 404 Error on https://localhost:8080/signalr/hubs. I think it may not be recognizing the hub, but I can't quite figure out how to register it. Any suggestions?

** This exact code worked when running a console application, but seems to fail now that it is being accessed via a service **

Frank Johnson
  • 163
  • 1
  • 12

3 Answers3

1

You might want to check something like this:

http://allen-conway-dotnet.blogspot.ch/2012/02/applying-and-using-ssl-certificate-with.html

It's not as simple as for http, or for https+IIS.

UPDATE

Ok, I read it more carefully and I think you have a major fault, you are calling your Start method inside a using(...) block, which means that you close your hosting immediately (the OnStart method exits). Remove your using(...) block and it should work (I tested it with http).

Also, the AppDomain stuff is not needed at all, given the fact that MyHub is referenced in your project.

Wasp
  • 3,395
  • 19
  • 37
  • I don't think the error is related to Http/Https, I think it is more directed at the service, which is hosting SignalR, is not able to find the hub in a referenced file. – Frank Johnson Jun 06 '14 at 12:54
  • That did the trick! I spent so long on that issue, I knew it had to be something simple that I was overlooking! Thank you! – Frank Johnson Jun 09 '14 at 12:47
0

How about the configuration: link And just out of curiosity: does the hub work with HTTP only? (without SSL?)

EDIT: Change the url from https://localhost:8080 to https://127.0.0.1:8080 and try again.

Community
  • 1
  • 1
martin
  • 289
  • 1
  • 6
  • The hub works currently in the console app over HTTP and HTTPS – Frank Johnson Jun 06 '14 at 12:15
  • But does the hub work from the Windows Service with http only? – Wasp Jun 06 '14 at 12:27
  • What account is the windows service running as? – martin Jun 06 '14 at 12:39
  • @Wasp, No, it does not. – Frank Johnson Jun 06 '14 at 12:52
  • @martin The service is running as Local System. – Frank Johnson Jun 06 '14 at 12:53
  • @FrankJohnson please look at my revised answer – martin Jun 06 '14 at 12:59
  • I have switched in the Service, do I also need to switch it in the hub project to `https://*:8080`? And will I also need to switch the client as well? – Frank Johnson Jun 06 '14 at 13:37
  • Your service probably started OK but the reason you are not finding your hub probably lies in the IP protocol implementation. When service is running, it is running as Local System and that may be using your assigned IP (192.168.?.?) or 127.0.0.1 (default loopback). The same thing happens when you host your application in IIS - at that point it is only available through http://localhost from the local machine but not from remote machines. Something similar seems to be happening here. So yes, change all the addresses to the same string and try it out. If it works OK, else make a config file. – martin Jun 06 '14 at 13:43
0

change the port on your connection string to 443 like this

const string url = "https://localhost:443";

or not using ssl

 const string url = "http://localhost:8080";
Shachaf.Gortler
  • 5,655
  • 14
  • 43
  • 71