Reputation: 95
I have a signalR server implemented in Dotnet Core 2.0, below is the code for the server
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSignalR ();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
app.UseSignalR (routes => {
routes.MapHub <NotificationsHub> ("notificationshub");
});
}
NotificationsHub.cs
public class NotificationsHub : Hub
{
}
Then, in a controller I have got this in a GET Method (which does a bunch of stuff and then is supposed to notify clients)
_hubContext.Clients.All.InvokeAsync ("appointmentConfirmation",name,message);
Now for the .NET client (3.5) I have the following code
var APIURL = "https://localhost:11111/notificationshub"
_notificationHub = new HubConnection(APIURL, false);
_notificationProxy = _notificationHub.CreateHubProxy("NotificationsHub");
_notificationProxy.On<String,JObject>("appointmentConfirmation",
(name, message) =>
{
//
});
await _notificationHub.Start();
However, it throws an exception saying 404 Not Found
.
Upvotes: 1
Views: 4323
Reputation: 342
You're using different versions of SignalR on your client and server.You can't mix and match versions of SignalR. You can look at the samples located at https://github.com/aspnet/SignalR/tree/dev/samples/ClientSample and https://github.com/aspnet/SignalR-samples to see how to get simple SignalR Core apps started.
Upvotes: 3