Reputation: 1546
I'm trying to get the SignalR self-hosted example working.
I create a new console application, install the 3 packages and add the code here, and run the application without any errors.
Before running netstat shows nothing listening on 8080, while running there is something listening on 8080.
When I go to http://localhost:8080/signalr/hubs
I get "Connection refused"
Update: Running the demo project from here throws No connection could be made because the target machine actively refused it 127.0.0.1:8080
(after starting the server successfully, of course).
It seems that the problem is with the Owin host but I've never used it, so I have no idea how to go about debugging it.
Upvotes: 2
Views: 1892
Reputation: 890
I have also had this issue. Most examples I have seen for this kind of SignalR code use a "Using" keyword to start the WebApp. This causes the WebApp to be destroyed when it falls out of scope. In some examples, all of the necessary work has been done by this point, but if you're trying to connect to the SignalR server, you need to keep this object alive and in-scope.
Instead of code like this...
using (WebApp.Start(url))
{
// Example SignalR usage here
}
Try something more akin to the following...
private readonly IDisposable webApp; // Declared in your class fields
then
webApp = WebApp.Start(url);
Be sure to dispose of the object when you're done with it.
Upvotes: 2
Reputation: 1764
Make sure you keep the web app alive.
Crude example code follows...
using (WebApp.Start<SignalrStartUp>(SignalrStrings.SignalrBaseUrl))
{
while(true)
{
Task.Delay(TimeSpan.FromSeconds(1)).Wait();
}
};
Upvotes: 4
Reputation: 7692
Make sure you are allowing connections to the same machine; try yourmachinename, localhost and 127.0.0.1. Also start application as administrator (easiest with ctrl-shift).
Then when you have got it running - look into how to set up you user to allow for network access.
If you are using Visual studio you might run into js files not existing. Set the respective js files to "copy if newer".
Upvotes: 0
Reputation: 1
You need to create a folder called signalR in the root of your web app so signalR has somewhere to map to.
Upvotes: -2