-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Server side Blazor + Paste large amount of text into text area with binding = Disconnection of client #5623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you see any exceptions in the logs on the server? You can check the server logs by selecting ASP.NET Core Web Server in the output tab in VS. You might be hitting the default buffer size limit in SignalR. See https://github.com/aspnet/Blazor/issues/1614#issuecomment-433983017 for additional details. |
There is a message in the server logs referring to an exception BackpressureDeadlock:
Following the referenced issue with SignalR buffer size takes care of the issue, but shouldn't the implementation of the client 'chunk' a large buffer so as not to cause an overflow?
|
@anurse Thoughts on this? |
We don't automatically chunk. The streaming functionality makes it possible for users to chunk the data themselves, but we have no plans to automatically chunk data. SignalR isn't really well suited to sending large payloads. |
@SteveSandersonMS @rynowak We should discuss if we want to do anything here beyond telling folks to increase the SignalR buffer sizes. |
i would appreciate if JSInterop would implement chunking on top of SignalR. Setting buffer size delays the problem but not solves it. The case where i needed to pass a string >32k i split it into substrings and called the interop function several times with the substrings and offsets. This works but it's not nice. |
I agree with @Kaffeegangster that setting a buffer size merely hides an implementation issue. After all, you can't predict what an end user is going to do when using an app. |
@danroth27 @rynowak I agree with @MarkStega that increasing the buffer size isn't really a proper solution. There's no scenario I can think of where you'd want there to be an arbitrary size limit on the diff. So, either Razor Components has to implement chunking on top of SignalR, or SignalR itself needs to. I don't mind desperately either way, but since supporting that would benefit all SignalR apps, I think we should at least discuss a bit more with the SignalR folks if it would be viable as a future SignalR feature, otherwise the Razor Components implementation would be a standalone thing that doesn't benefit anyone else. CC @anurse @davidfowl. |
We've long avoided automatic chunking (in both ASP.NET and ASP.NET Core SignalR), I don't see it being a feature we intend to support. Besides, it's only possible for us to fix this at the Hub layer, and if you use |
@anurse Would it justify having some thin layer on top of |
Perhaps, but I don't think that would be a public API component. I could see building a shared-source component for this. I don't think we'd use it in SignalR as we haven't really seen demand for it at the Hub layer (since Hubs aren't really designed for large data anyway and have their own streaming primitives). In 3.0 we currently plan to add the ability to "stream" data as a parameter (much like you can stream results) which might also help here, but again, only for the Hub layer. |
I don’t quite understand the chunking request, are you asking for streaming? The limit is about total buffered memory so this needs to be implemented in the app layer. |
@davidfowl I haven't reproduced the issue so I'm not certain what the ideal resolution would be. I think what we need for sure is the ability for the server to dispatch an arbitrarily large message to the client, since the render tree diff could be arbitrarily large. Streaming may not be relevant, since the server already has the data in a buffer in memory. On the other hand, we don't necessarily need to let the client send an arbitrarily large message to the server. I'm aware that if we do, then there are DOS concerns since the server would need to allocate a correspondingly-sized buffer (and there's no equivalent DOS scenario in the server->client direction). Perhaps there isn't any problem to solve here, other than possibly implementing JS interop support for streams at some point in the future. The only short-term problem is if the server->client direction has arbitrary size limits despite the data already being in some |
For my use case i need to send a bigger (a few 100 kb) string (xml) from the server->client and later back from client->server to save it in a database. |
@Kaffeegangster I agree that support for streaming would be valuable. I think that's the right solution for sending arbitrarily large amounts of data from client to server. We wouldn't implement a non-streaming way to send arbitrarily large blocks of data, because that would be a DOS risk to the server. |
I am also seeing this error if I put 31085 chars in a textarea with a bind property in blazor server-side. If i put 31084 chars it works, anything higher i see the same error. 31085 chars is not much, if you write a blog article in a textarea it will exceed that probably. Any solution or workaround for that? |
The reference in Dan's post right after the first post "( See #1614 fo additional details.)" for a short term work-around for this implementation issue. |
How to do it using .netcore 3.0 and blazor ? Is there any workaround for this using .net core 3.0 ? app.UseEndpoints(endpoints => {
|
had the same issue using Microsoft.AspNetCore.SignalR; |
Max size I can paste is 16290 chars. |
This fixed my problem: services
.AddServerSideBlazor()
.AddHubOptions(x => x.MaximumReceiveMessageSize = 102400000); |
Can confirm the comment above worked for me as well. This seems like a pretty big issue. I have a razor page with a decently long table (79 rows), and for each row I added a razor component, this was enough to make the request 33KB and I got this error, took me an hour to figure out what is happening (initially thought my component was broken). |
Hello, thanks for contacting us. This issue was also discussed as part of #30291, and we added a sample app to document working with large text areas in Blazor: https://github.com/aspnet/samples/tree/main/samples/aspnetcore/blazor/InputLargeTextArea |
I have a server side execution Blazor app that is displaying a text area with a simple 'bind="@backingProperty"'. If I paste moderate amounts of text into the text area everything functions as it should. However, if I paste a large amount of text (it happens to be a base64 representation of an image in some html) then the connection is closed with the following error appearing:
The text was updated successfully, but these errors were encountered: