Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR: How to reacquire client info after app pool recycle

Tags:

signalr

At connect time, I map the clientID to other client and subscription info which I build in a static variable. This works fine until the app pool recycles or I recompile and then I lose my mappings.

Client connections persist after the app pool recycle, but I am not seeing anything in either the OnConnectAsync() or OnReceivedAsync() methods.

I see in Firebug that a new POST is being submitted by my clients every 4 minutes. Is there some SignalR event that I can override to capture the incoming POST and rebuild my client mapping for the current persistent connections?

Thanks.

like image 310
codezoo Avatar asked Oct 09 '22 15:10

codezoo


1 Answers

Make sure you're using SignalR 0.4. You can handle OnReconnectedAsync.

https://github.com/SignalR/SignalR/wiki/PersistentConnection

DISCLAIMER: If you store your application state in static variables it will never be able to scale out on a farm (but maybe you don't care).

like image 68
davidfowl Avatar answered Oct 14 '22 01:10

davidfowl