Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

HubConnectionHandler Crash When Sending Large Amounts of Data #2322

Closed
Jon-Murray opened this issue May 19, 2018 · 4 comments
Closed

HubConnectionHandler Crash When Sending Large Amounts of Data #2322

Jon-Murray opened this issue May 19, 2018 · 4 comments
Milestone

Comments

@Jon-Murray
Copy link

Jon-Murray commented May 19, 2018

Hi Guys,

I have been testing and have found the following crash whenever a "large" (2MB in my test) amount of data is sent from the server -> client. The crash occurs in the following code within HubConnectionHandler.cs:

            finally
            {
                // The buffer was sliced up to where it was consumed, so we can just advance to the start.
                // We mark examined as buffer.End so that if we didn't receive a full frame, we'll wait for more data
                // before yielding the read again.
                input.AdvanceTo(buffer.Start, buffer.End);
            }

I've modified it slightly, but here is my console output for an example crash:

Buffer start: 429 end : 429
Buffer start: 0 end : 2048
Buffer start: 0 end : 2048
Buffer start: 0 end : 2048
System.InvalidOperationException: Advancing examined to the end would cause pipe to deadlock because FlushAsync is waiting.
   at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_BackpressureDeadlock()
   at System.IO.Pipelines.Pipe.AdvanceReader(BufferSegment consumedSegment, Int32 consumedIndex, BufferSegment examinedSegment, Int32 examinedIndex)
   at System.IO.Pipelines.Pipe.AdvanceReader(SequencePosition& consumed, SequencePosition& examined)
   at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed, SequencePosition examined)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.DispatchMessagesAsync(HubConnectionContext connection) in C:\Users\Jon\Desktop\testproject\SignalR_2_1_\Microsoft.AspNetCore.SignalR.Core\HubConnectionHandler.cs:line 215

This would then crash the connection (i.e. uncleanly close it for all clients that the file is being pushed to). The test functionality in question is uploading an image to redis (as a blob) over HTTP, then retrieving it via SignalR to the clients. I appreciate a lot has changed, but there was no issue with this in previous (< core 2.1) code. Unsure as to what else i can do here to help but if there's anything more please let me know.

Cheers!

@davidfowl
Copy link
Member

See #2266 (comment). This is by design.

@davidfowl davidfowl added this to the Discussions milestone May 19, 2018
@Jon-Murray
Copy link
Author

Jon-Murray commented May 19, 2018 via email

@davidfowl
Copy link
Member

@Jon-Murray I'd recommend using http for large file uploads until SignalR gets streaming support from client to server.

@davidfowl
Copy link
Member

The issue I referenced outlines the current issues with large uploads and the danger in increasing the max buffer size if your application is exposed to anonymous users. I've filed this issue to look at addressing the problem https://github.com/aspnet/SignalR/issues/2320

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants