Skip to content

UseSignalR and UseConnections are marked obsolete #14928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ajaybhargavb opened this issue Oct 3, 2019 · 2 comments · Fixed by #15044
Closed

UseSignalR and UseConnections are marked obsolete #14928

ajaybhargavb opened this issue Oct 3, 2019 · 2 comments · Fixed by #15044
Assignees
Labels
breaking-change Indicates a .NET Core breaking change

Comments

@ajaybhargavb
Copy link

ajaybhargavb commented Oct 3, 2019

UseSignalR and UseConnections are marked obsolete

The methods UseConnections and UseSignalR, and the classes ConnectionsRouteBuilder and HubRouteBuilder are being marked obsolete in 3.0.

Version introduced

3.0

Old behavior

SignalR hub routing was configured using UseSignalR, UseConnections.

New behavior

The old way of configuring routing has been obsoleted and replaced with Endpoint routing.

Reason for change

We're moving middleware to the new EndpointRouting system so we're obsoleting the old way of adding middleware.

Recommended action

Replace UseSignalR with UseEndpoints,

Old code:

app.UseSignalR(routes =>
{
    routes.MapHub<SomeHub>("/path");
});

New code:

app.UseEndpoints(endpoints =>
{
    endpoints.MapHub<SomeHub>("/path");
});

Category

ASP.NET Core

Affected APIs

Microsoft.AspNetCore.Builder.IApplicationBuilder.UseSignalR
Microsoft.AspNetCore.Builder.IApplicationBuilder.UseConnections
Microsoft.AspNetCore.Http.Connections.ConnectionsRouteBuilder
Microsoft.AspNetCore.SignalR.HubRouteBuilder


Issue metadata

  • Issue type: breaking-change
@omuleanu
Copy link

using the obsolete code, my webapp works (netcoreapp3.1),
but as soon as I use the new way, in my case:
endpoints.MapHub<SyncHub>("/syncHub");
I get the error:

VM68:16 Uncaught (in promise) Error: Failed to invoke 'Send' due to an error on the server.
at _this.callbacks. (:16:35838)
at HubConnection.processIncomingData (:16:38004)
at WebSocketTransport.HubConnection.connection.onreceive (:16:27722)
at WebSocket.webSocket.onmessage (:16:110678)
_this.callbacks. @ VM68:16
HubConnection.processIncomingData @ VM68:16
HubConnection.connection.onreceive @ VM68:16
webSocket.onmessage @ VM68:16

when calling connection.invoke

@omuleanu
Copy link

turns out using the new endpoints.MapHub you have to send the exact parameter type you defined in the Hub,
I was sending: connection.invoke("Send", key) // key being int
and in the hub I have:
public async Task Send(string key)
so now I had to call toString() on key in js to make sure it is the same type as in the hub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants