Reputation: 127
I need to connect to an ASP.NET SignalR hub from JavaScript. I am using the @aspnet/signalr npm package, with the following code to connect.
connection = new signalR.HubConnectionBuilder()
.withUrl("<link to hub>", { accessTokenFactory: () => token })
.build();
connection.start()
The same code works to connect to an ASP.NET Core SignalR hub, but for an ASP.NET SignalR hub, it returns the following error: TypeError: Cannot read property 'length' of undefined at "HttpConnection"
Is this an issue with incompatible versions? Can the @aspnet/signalr package be used to connect to an ASP.NET SignalR hub?
Upvotes: 3
Views: 2076
Reputation: 1439
Short answer, no you cannot use/mix the client/server packages. ASP.NET Core SignalR isn't compatible with clients or servers for ASP.NET SignalR.
See my older post/accepted answer here - https://stackoverflow.com/a/49153217/6263514
But for newer reference the docs here - https://learn.microsoft.com/en-us/aspnet/core/signalr/version-differences?view=aspnetcore-5.0
Upvotes: 2