83
Views
5
Comments
Solved
[SSE Push Event Hub] Server cannot set status after HTTP headers have been sent.
sse-server-event-hub-and-client
Service icon
Forge asset by Nuno Damaso
Application Type
Reactive

Hi Nuno,

Thanks for this awesome forge component! it works like a charm. While it does work it also fills our error log with the message "Server cannot set status after HTTP headers have been sent." Have you encountered this issue before and do you have any suggestions on how to solve this error from occurring? We implemented the component according to your demo application.


Error stack:

"
Server cannot set status after HTTP headers have been sent.
at System.Web.HttpResponse.set_StatusCode(Int32 value)
at System.Web.Http.WebHost.HttpControllerHandler.<CopyResponseStatusAndHeadersAsync>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.<CopyResponseAsync>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.<ProcessRequestAsyncCore>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)

"

2024-09-08 11-13-40
Nuno Damaso
 
MVP
Solution

Fixed for 1.0.5

2024-09-08 11-13-40
Nuno Damaso
 
MVP

Hi Jørgen,

Yes I have, I actually mention this issue at the "Known Issues" section at the Docs tab.


If you don't mind, I'll hijack this thread to see if anyone can help me on this.


There is no "real" error here, what is happening is the following:

- a web client connects to the SSE hub via the rest api

- the first SSE event delivered to the connected client is sent with the proper headers for messaging flush

- the client eventually disconnects

- outsystems has no proper way (as far as I can tell), to completely abort the ongoing rest request, and still sends a response through iis to the disconnected client

- IIS knows that the headers were previously sent by the SSE and issues the message that you are seeing


I am actively looking for ways to overcome this and surpress this log message, but haven't had any luck yet. I've tried:

- Throwing and catching an error at the end. Outsystems still sends a response

- Aborting the transaction. Outsystems still sends a response

- Killing the HttpRequest at a lower level (dll). No luck

- Surpressing the rest log for the action. Still sends.



As you mentioned, this log pollution is burdensome :(

2024-09-08 11-13-40
Nuno Damaso
 
MVP

Bump

I'm actively trying to fix this to allow for "gracefull disconnects", but running out of ideas. 

If someone has any fresh ideas please fell free to drop me a msg.

UserImage.jpg
Sc ott

Hi Nuno,


I was searching for a solution to this very issue. So far all I could locate is the following link. So I signed up for this site in the hopes you find it useful:

http://www.dotnet-concept.com/Tips/2015/10/5798837/Error-Server-cannot-set-status-after-HTTP-headers-have-been-sent-MVC

2024-09-08 11-13-40
Nuno Damaso
 
MVP

Hi Scott, all


I already have it fixed thanks to an ingenious approach from @Leonardo Fernandes , thanks again Leonardo!

I'll have it patched soon (this weekend probably)

2024-09-08 11-13-40
Nuno Damaso
 
MVP
Solution

Fixed for 1.0.5

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.