Skip to content

[Question] How to emit heartbeat/comments with Results.ServerSentEvents in .NET 10? #65103

Closed

Description

@DevisTedeschi99

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.ServerSentEvents implementation with IAsyncEnumerable<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.ServerSentEvents handling the IAsyncEnumerable serialization automatically, we cannot find a way to inject these heartbeat frames.

  1. Is there a built-in configuration to enable automatic heartbeats?
  2. If not, Do you have any suggestion on what would be the best way to achieve the same using this new API?

Many thanks in advance!

Activity

  1. added
    needs-area-labelUsed by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
    on Jan 16, 2026
  2. added
    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
    and removed
    needs-area-labelUsed by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
    on Jan 27, 2026
  3. bradleyables22 commented on Feb 23, 2026

    @bradleyables22

    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

  4. locked and limited conversation to collaborators on Jun 10, 2026
  5. converted this issue into a discussion #67133 on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions