We have encounter performance issue where the MssHeartBeat ping threads get stuck in IIS from the moment user login all the login till the user logout. When there too many user login and stay in the system for long time, there will be many stuck threads in the IIS for MssHeartBeat in outsystem
We have tried to change the code from sync to async using aysnc await task but we hit issue after changing to async approach.
Error is as follow:
domain/SingleUserSignIn_CS/rest/
StackServer cannot set status after HTTP headers have been sent. at System.Web.HttpResponse.set_StatusCode(Int32 value) at System.Web.Http.WebHost.HttpControllerHandler.d__25.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.WebHost.HttpControllerHandler.d__15.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.WebHost.HttpControllerHandler.d__12.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Please help to advise does this component support async for the MssHeartBeat ping .
And will changing to async for MssHeartBeat break any component in the SSE_IS
e.g Original code from SSE_EXT.cs. for pinging to client from server
public void MssHeartBeat(string ssGuid, decimal ssSleep, string ssChannel) {
...
..
while (ssSuccess)
{
Sleep(ssSleep);
CreateChannelIfNotExists(ssChannel);
....
}
async approach code adjustment
public void MssHeartBeat(string ssGuid, decimal ssSleep, string ssChannel)
MssHeartBeatAsync(ssGuid,ssSleep,ssChannel);
} // MssHeartBeat
public async Task MssHeartBeatAsync(string ssGuid, decimal ssSleep, string ssChannel)
try
var ssSuccess = true;
/*Sleep(ssSleep);*/
await Task.Delay(TimeSpan.FromSeconds(decimal.ToInt32(ssSleep)));
Hi Kah Leong Ng
Please notice the following:
- Upgrade both your components to the latest versions [SSE Push Event HUB 2.0.6] and [SSE Reactive Client 1.0.5]
- The HeartBeat method is supposed to be synchronous. Failing to do so will exit the thread, force the http end sending the headers, resulting in what you are observing. The heart beat keeps the connection open.
- You say "When there too many user login and stay in the system for long time, there will be many stuck threads in the IIS". Please have in mind that these are not "stuck" threads - this is what Server Sent Events do. They persist a connection from your app to your server through HTTP.
I would advise you to revise if SSE does fit your needs - it's supposed to be for light-weight signaling, and maybe switch to other server event techs if it doesn't fit - firebase, websockets etc. (although you will have to use a 3rd party and info will not be maintained within your OutSystems envs).
Or perhaps increase resources within your OutSystems infra?
All in all, remember that SSE persists a REST HTTP connection between your server and your client.