Deploying Self Hosted SignalR

2019-03-20 04:34发布

问题:

I have created a pair of C# based console apps based on this SignalR Console app example.

This works brilliantly on my local PC, and I have now copied the server app (plus all files from the bin/Release folder) onto my server. When I run the server app, it happily sits there listening on "http://www.redacted.com:8088/".

In the client app, I changed:

var _connection = new HubConnection("http://127.0.0.1:8088/");

to:

var _connection = new HubConnection("http://www.redacted.com:8088/");

However I now get a 503 Server Unavailable error when I try to start the connection. I'm a newbie to SignalR, and haven't managed to find a decent tutorial with regards to deployment (largely because there are probably so many different ways it can be done depending on requirements I guess).

So my questions are:

  1. Do I need to set anything up in IIS for this to work (bearing in mind I'm not looking at this being web based, just console app to console app), or is it okay to just run the server exe and open the port up?

  2. My server is running Windows Server 2012, and I have added my exe to the list of applications that are allowed to make connections, and have added an incoming rule for port 8088, is there anything else I need to do in order to be visible to my client?

回答1:

If you have something along these lines on the server

      string url = "http://127.0.0.1:8088/";
      var server = new Server(url);
      server.MapHubs();
      server.Start();

Try binding to all IPs (or hosts)

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