Describe the bug
#47 was never fixed but was closed because a workaround was discovered.
Although increasing the Message size like
services.AddSignalR(hubOptions =>
{
hubOptions.MaximumReceiveMessageSize = 10 * 1024 * 1024; // 10MB
});
might work, this isn't a proper solution.
In our application we store our users entire form data in Session. This should not be an issue as the form data doesn't exceed the limit. What happens though is that when trying to set an item (which should add or replace) or get an item (which I'm a bit puzzled with) it instead throws a System.IO.InvalidDataException from SignalR and if Common Language Runtime Exceptions are enabled, it will throw the exception from HubConnectionHandler.cs at line 254 with throw new InvalidDataException($"The maximum message size of {maxMessageSize}B was exceeded. The message size can be configured in AddHubOptions.");
I've done extensive research and have come to the conclusion of 2 possibilities.
- For
SetItemAsync, the old item is having the new item appended to it.
- The SignalR connection is not being disposed of correctly causing a memory leak (Once I have the tools to debug this, I can report back).
Based on both SetItemAsync and GetItemAsync throwing the same exception, I'm leaning towards something more like option 2.
In either case simply leaving the solution to be increase the message size is treating a symptom and not the cause. I could easily increase my form data in the future, and still be under whatever my threshold is (unless I define no limit or a ridiculously high limit) and run into the same issue.
To Reproduce
Create a item that's close to the 32k default SignalR message limit.
Save the item.
Get the Item.
Or
Save the item, then re-save the item.
Expected behavior
In both instances, if the original object is less than the 32k and the new object is less than 32k, there should be no SignalR exceptions thrown and the functions should complete their task successfully.
Hosting Model (is this issue happening with a certain hosting model?):