SignalR Hub - Check for incomming or outgoing data

Marcel Lorenz 81 Reputation points
2022-03-17T22:47:15.843+00:00

I want to implement the feature to properly shut down all SignalR hubs before shutting down, the server, to roll out a new application version. I want the REST API to finish all currently managed requests but not to accept new requests. That's already implemented. Also, I want to shut down all hubs. The problem is that a REST requests connection is closed when it's done, so it's easy to determine if there are still requests, that have to be finished. But a Hub connection is always active unless it's closed on purpose or something went wrong. So I want to shut down the hub if no data is currently transmitted. Is there a way to check for this information?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,418 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,650 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 61,731 Reputation points
    2022-03-18T15:36:25.497+00:00

    you should add a broadcast message to clients, telling them to disconnect, perhaps with time to wait before reconnect..


  2. Jose Zero 576 Reputation points
    2022-03-20T12:38:11.627+00:00

    This article might help you or at least give an starting point
    tracking-online-users-with-signalr

    0 comments No comments