I know it might be more an IIS thing but I am really struggling to have my SS rest api app pool to recycle properly. I have 2 separate websites each on their own port and app pool. Site A is the WebApp and Site B is the SS WebAPI. Site B has the Disable Overlapped Recycle to TRUE.
When Site B recycles, I will hit the Application_End (still .net 4.7.2) and I can dispose of my resources just fine BUT ONLY if there is no user connected with SSE. When there is at least one connected user, the worker process will not shut down until it reaches its Shutdown Time Limit (whatever the limit i put). When that happens, there is no place in the api code that triggers to let me do something. When worker process hits its limit, the Site B will restart (when receiving a request) but no dispose will have happened.
Anybody having that issue? I cannot find anything useful out there.
Is it because of the way I implemented SSE on my API? I use the basic settings nothing fancy.
Any help is appreciated, running into some production downtime issue at a high valuable customer because of this.
Hi @mythz , thanks for your quick reply. I have that call inside the Application_End but that method is never called when the recycle happens with active connections. There is no other entry point I can find to have code executed to call the Stop when the recycle triggers.
You’d need to explicitly call it to terminate the connections before you want to recycle the App. I’m not aware of any recycling/pre shutdown Application events.
But the thing is that IIS does initiate the recycle based on its time interval and as soon as it does, no code is executed on my side to trap it and close the connections. Would I have to not have IIS handle the recycling and have a script somewhere to initiate a recycle? How people do it out there? I can’t be the only one experiencing this egg or chicken thing.
I ended up managing the recycle myself inside my app where I can call the StopAsync beforehand.
One question though.
The Stop disposes the current subscriptions and resets them but it doesn’t prevent new subscription to be accepted while doing the stop…While stopping, clients were able to subscribe 10ms later before the recycle could happen so I ended up still having opened connections…
Is there anyway to stop and maybe prevent any new connections at all or at least for a period of time?