2
votes

I have asp.net core web api server that is streaming a signalr, And it works for asp.net client , I am trying to make a connection with the code showen beelow but it only connects to a none core servers it wouldnt work for the core servers.

//the hub class in the server code
[EnableCors("AllowAllOrigins")]
[HubName("LogNotifierHub")]
public class LogNotifierHub : Hub
{
   //methods defined here 
}

startup code for the routing :

 app.UseSignalR(routes =>
            {
                routes.MapHub<LogNotifierHub>("/NotifierHub");
            });

javascript code for making the connection

var hubUrl ="http://localhost:52273/logNotifierHub";

var connection = $.hubConnection(hubUrl, { useDefaultPath: true});
var hub = connection.createHubProxy("LogNotifierHub");

hub.on('SendStreamInit', function(data){
            console.log( data)
})                  

connection.start()
   .done(function(){ console.log(' connected!! connection ID=' + connection.id); })
   .fail(function(error){ console.log('Could not connect!!' + error); }); 
1
Is this actual code? You are missing some ;'s in your js. Futhermore: do you receive errors when trying to connect? If so, post them please. - Stefan
Yes it is @Stefan, It doesnt complain about the ;'s the only error am getting is Error during negotiation request. I have made all the CORS setting to allow all origins - SANA
Are you getting any error? What is the error? - Pavan
; are inferred in js - but sometimes the infer gets it wrong. - freedomn-m
It WL connect to non core only to connect to core use node or typescript as per Microsoft guidelines.. read blogs.msdn.microsoft.com/webdev/2017/09/14/… - Pavan

1 Answers

5
votes

You can't mix and match version of the SignalR server and client. If you're using core on the server then you have to use it on the client as well.

From the MSDN SignalR alpha blog post

SignalR for ASP.NET Core is not compatible with previous versions of SignalR. This means that you cannot use the old server with the new clients or the old clients with the new server.