Disconnect from SignalR at the time of logout - ReactJS & Entity Framework

Viewed 82

I'm facing the issue regarding to disconnecting from signalR. I want to know that is there some way to disconnect the connection that is established between my frontend and the backend when i logout from the app.

Following npm package of signalR we are using on frontend:

@aspnet/signalr: 1.1.4

1 Answers
    //Log out 
    const logoutBtn=()=>{
      connection.stop() // This line will send a disconnected call to the server
      Logout()
    }

// Server code 
     public override async Task OnDisconnectedAsync(Exception? exception)
            {
               Context.ConnectionId // U will get the connection id that is disconnected 
            }
Related