Skip to content

Add configurable WebSocket buffer size per route #2386

Description

@erannevo

Expected Behavior / New Feature

Each route should support an optional WebSocketBufferSize configuration property
that overrides the default receive/send buffer size used in WebSocketsProxyMiddleware.

Actual Behavior / Motivation for New Feature

The buffer size in WebSocketsProxyMiddleware is hardcoded to 4096 bytes.
This causes choppy/degraded video streams over WebSocket connections when hosting
with HTTP.sys. HTTP.sys is more sensitive to small receive buffers than Kestrel
due to differences in kernel-level I/O handling — 4096 bytes is insufficient
for high-bandwidth routes such as video streaming.

Steps to Reproduce the Problem

  1. Host Ocelot with HTTP.sys (not Kestrel)
  2. Configure a WebSocket route proxying a video stream
  3. Observe choppy/degraded stream quality caused by the 4096-byte buffer limit

Specifications

  • Version: 25.0
  • Platform: .NET 10, Windows (HTTP.sys)
  • Subsystem: WebSockets

Activity

  1. raman-m commented on Apr 30, 2026

    @raman-m
    Member

    Hello, @erannevo
    Yes, it could be configurable.

    The buffer size in WebSocketsProxyMiddleware is hardcoded to 4096 bytes.
    This causes choppy/degraded video streams over WebSocket connections when hosting

    Got it!
    We can make the following property protected virtual:

    private const int DefaultWebSocketBufferSize = 4096;

    After that, inherit and override the property that can adjust the buffer size for each route. The injection of a new version of WebSocketsProxyMiddleware is another problem.

  2. erannevo commented on Apr 30, 2026

    @erannevo
    ContributorAuthor

    Hi @raman-m , Thank you for the quick reply ,
    I've already fixed & tested it.
    I've submitted a PR linked to this issue :
    #2387

  3. raman-m commented on Apr 30, 2026

    @raman-m
    Member

    @erannevo Eran?
    What's your full name?
    What's your LinkedIn profile?
    How many years have you been developing .NET apps?

  4. added
    WebsocketsOcelot feature: Websockets
    CoreOcelot Core related or system upgrade (not a public feature)
    on Apr 30, 2026
  5. added theissue type on Apr 30, 2026
  6. added
    acceptedBug or feature would be accepted as a PR or is being worked on
    on Apr 30, 2026
  7. raman-m commented on Apr 30, 2026

    @raman-m
    Member

    Accepted ✅ due to the linked PR #2387

  8. erannevo commented on Apr 30, 2026

    @erannevo
    ContributorAuthor

    @erannevo Eran? What's your full name? What's your LinkedIn profile? How many years have you been developing .NET apps?

    I've replied in the PR comment , I think its best to keep one "chat" active , hard to follow both :)

  9. added a commit that references this issue on May 28, 2026
  10. raman-m commented on May 28, 2026

    @raman-m
    Member
  11. added this to the .NET 10 milestone on May 30, 2026
  12. added
    Autumn'26Autumn 2026 release
    and removed
    NET10.NET 10 release
    on Jul 2, 2026
  13. modified the milestones: .NET 10, Summer'26 on Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Autumn'26Autumn 2026 releaseCoreOcelot Core related or system upgrade (not a public feature)WebsocketsOcelot feature: WebsocketsacceptedBug or feature would be accepted as a PR or is being worked onfeatureA new feature

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions