1

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.

Julien Rousé
  • 1,115
  • 1
  • 15
  • 30
THingamagick
  • 95
  • 1
  • 2
  • 13
  • Is the protocol HTTPS right, or should it be HTTP? – Ricardo Peres Jan 23 '18 at 11:18
  • SignalR for .NET Core is a complete rewrite and isn't released yet. What is available is still beta. It's not compatible with the older version either – Panagiotis Kanavos Jan 23 '18 at 11:18
  • Furthermore, the new clients target [.NET Standard 2.0](https://github.com/aspnet/SignalR/blob/dev/src/Microsoft.AspNetCore.SignalR.Client/Microsoft.AspNetCore.SignalR.Client.csproj). .NET 3.5 isn't even supported any more, the earliest supported .NET version is 4.5.2. Versions up to 4.7 need additional packages to .NET Standard 2.0 libraries. 4.7.1 has built-in support. You should upgrade to .NET 4.7.1 if you want to use SignalR for .NET Core – Panagiotis Kanavos Jan 23 '18 at 11:23

1 Answers1

3

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.

Mikael Mengistu
  • 332
  • 1
  • 6