Repository navigation
[Question] How to emit heartbeat/comments with Results.ServerSentEvents in .NET 10? #67133
Unanswered
DevisTedeschi99
asked this question in
Q&A
Replies: 1 comment
|
Hey Dude, casually browsing tickets and ran across this. Not really sure why this hasn't gotten a response. But here is how I recently implemented heartbeating. https://github.com/bradleyables22/Heimdall/blob/master/Heimdall.Server/Endpoints/BifrostEndpoints.cs starting at line 67 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
We are migrating our application from .NET 9 to .NET 10 and since we have many SSE endpoints and we are testing the new
Results.ServerSentEventsimplementation withIAsyncEnumerable<T>.Our infrastructure uses Nginx as a reverse proxy, which requires a periodic heartbeat (SSE comment lines starting with
:) to prevent connection closure due to idle timeouts.In our previous implementation, we were directly writing into the response buffer of HttpContext so we could manually mix data events and heartbeats into the stream.
With
Results.ServerSentEventshandling theIAsyncEnumerableserialization automatically, we cannot find a way to inject these heartbeat frames.Many thanks in advance!
All reactions