[SignalR] Allow controlling maximum buffer size on client
See original GitHub issueBackground and Motivation
We currently allow control over the “maximum buffer size” on the server: https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.1&tabs=dotnet#advanced-http-configuration-options
(We derive the PauseWriterThreshold and ResumeWriterThreshold values from that).
However, we don’t let the .NET client configure this. We should consider doing so to allow the client better control over backpressure.
This is important for high performance scenarios where the users might be receiving a large batch of data e.g https://github.com/dotnet/aspnetcore/issues/34895 and want to control how much memory is OK to allocate for unprocessed messages.
Proposed API
namespace Microsoft.AspNetCore.Http.Connections.Client
{
public class HttpConnectionOptions
{
+ /// <summary>
+ /// Gets or sets the maximum buffer size for data read by the application before backpressure is applied.
+ /// </summary>
+ /// <remarks>
+ /// The default value is 1MB.
+ /// </remarks>
+ public long TransportMaxBufferSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum buffer size for data written by the application before backpressure is applied.
+ /// </summary>
+ /// <remarks>
+ /// The default value is 1MB.
+ /// </remarks>
+ public long ApplicationMaxBufferSize { get; set; }
}
}
Usage Examples
var hubConnection = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/chat", o =>
{
// Set the transport buffer size to 30 MB before yielding
o.TransportMaxBufferSize = 1024 * 1024 * 30;
})
.Build();
Risks
None
Notes:
- This mirrors the properties on the server side, but the naming isn’t great. Transport -> transport to application buffer (inbound) and Application -> application to transport (outbound).
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (19 by maintainers)
Top Results From Across the Web
Security considerations in ASP.NET Core SignalR
By default, SignalR limits these buffers to 32 KB. The largest message a client or server can send is 32 KB. The maximum...
Read more >SignalR Performance
DefaultMessageBufferSize : By default, SignalR retains 1000 messages in memory per hub per connection. · Max concurrent requests per application: ...
Read more >Can I reduce the Circular Buffer to "1"? Is that a good idea?
The primary purpose of this minimum buffer size is to ensure that SignalR's long-polling transport works somewhat reliably.
Read more >How to Increase the Blazor SignalR Maximum Message Size
The SignalR WebSocket has a default maximum message size of 32 KB. A large Editor Value , FileSelect file size, or a PDFViewer...
Read more >Advanced SignalR configuration: fine-tuning the server-side ...
This option represents the maximum buffer size for the data exchange in the application layer in bytes. By default, it's set to 65...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And also should have an AppContext switch to disable this just in case.
Right, and if we backport, we can only backport the default value