简体   繁体   中英

SignalR clients are not disconnected after site was stopped on IIS

We have asp.net mvc application with SignalR hub which hosts on IIS. Let's name it SignalR Service. Some internal services can send a request to SignalR Service to notify external clients about any event. It's important for external clients to see state of connection to SignalR Service. And clients must be notified that SignalR Service is not available as soon as possible so clients know they will not get any notifications.

The issue starts when I stop the SignalR Service on IIS. Since process of SignalR Service exists after stopping the connections of clients are not dropped. So clients can't recognize that site is stopped. Since site is stopped it is not reachable for internal services and they can't send any notification to external clients.

So behavior of all services is expected but it doesn't fit to our business logic.

What can we do to make SignalR Service drop connections when is is stopped on IIS? Is that workflow with site on IIS good idea at all?

Please find the answer below to know how to disconnect all zombie connections, when IIS stops and starts.

Note : When you restart AppPool, the reconnection event is fired. But when you restart website, completely new application cycle begins, in this case you use HubPresence monitor which compares physical connection(in memory object) with db connections stored.

Building a simple presence manager for SignalR, https://patdunn.net/2015/05/05/building-a-simple-presence-manager-for-signalr/

Let me know if it helps or any other possible solution you have identified. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM