Provide an extra private readonly property on the SignalR HubConnectionContext
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
Currently there is no way for us to know way to calculate size of the payload content sent to signal r.
As confirmed in https://github.com/dotnet/aspnetcore/issues/59335#issuecomment-2521029996
Not having any mechanism to determine this size makes it very difficult to accurately set the ``MaximumReceiveMessageSize`` for SignalR.
### Describe the solution you'd like
As we already have a bunch of private readonly properties we can inspect on the HubConnectionContext when we break on the ``InvalidDataException`` inside ``DispatchMessagesAsync`` while in debug mode with ``Common Language Runtime Exceptions`` enabled as shown below.

Please add an additional private readonly property which only contains the buffer length that is used to compare against the ``maxMessageSize`` inside
```
if (segment.Length > maxMessageSize)
{
segment = segment.Slice(segment.Start, maxMessageSize);
overLength = true;
}
```
The ability to understand the message size sent to appropriately adjust the ``MaximumReceiveMessageSize`` is highly requested, searched for and mentioned in Stackover and Reddit.
We don't need any sort of mechanism to calculate the payload size programmatically, but we do need a way to know what the ``MaximumReceiveMessageSize`` is compared against to ensure we have a large enough ceiling while also not sacrificing performance.
Contributor guide
Assessment
This issue has not been assessed yet.