I'm trying to use SignalR to distribute status updates to listening clients. However my clients are failing with "404 Not found" when attempting to start the connection.
I've used https://learn.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-getting-started-with-signalr-and-mvc as a starting point, although I want a C# client not a scripted web page.
I've completed the following steps for the hub:
- AspNet Web Application (.Net Framework 4.5.2) added to solution
- SignalR Hub class added
- Owin start-up class added
- Application created under IIS virtual path /MyService .Net CLR version 4.0 Integrated Managed Pipeline Service account identity
- Client created with connection code as shown
For the most part my testing has revolved around trying the two different connection classes (Connection and HubConnection) using a variety of different URL.
The server side uses a hub and Microsoft.AspNet.SignalR version 2.4.1 library
using Microsoft.AspNet.SignalR;
namespace MyService
{
public class JobStatusHub : Hub
{
public void Send(string name, string message)
{
Clients.All.broadcastMessage(name, message);
}
}
}
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(MyService.Startup))]
namespace MyService
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
There will be two types of clients; message providers and message consumers. So far I have only worked on a message source which contains the following code using Microsoft.AspNet.SignalR.Client version 2.4.1
var connection = new Connection("http://localhost/MyService/signalr/");
connection.Credentials = CredentialCache.DefaultCredentials;
connection.Start().Wait();
And also
var connection = new HubConnection("http://localhost/MyService/signalr");
connection.Credentials = CredentialCache.DefaultCredentials;
connection.Start().Wait();
I have tried a variety of connection strings
Interesting aside: when I attempt to connect to a .Net CORE hub using
var connection = new Connection("http://localhost/MyCoreService/myHub");
connection.Credentials = CredentialCache.DefaultCredentials;
connection.Start().Wait();
The client appears to get further as it throws
StatusCode: 405, ReasonPhrase: 'Method Not Allowed'
Does anyone have any suggestions as to what might resolve this “404 Not found” error? Or am I making a mistake not using a CORE service and hub (when I looked up the Method Not Allowed error the results suggested I couldn’t use a Framework 2.4.1 client with a CORE hub)?