BedrockFramework icon indicating copy to clipboard operation
BedrockFramework copied to clipboard

Issue with Http1 Reader

Open Drawaes opened this issue 5 years ago • 2 comments

When reading requests in a loop I end up with the exception below, I do not have an issue when reading from the server in a tight loop with http client (ensuring a single connection). There is a gist with both the client code I am using and the server code (both bedrock)

https://gist.github.com/Drawaes/699b42621f31d83f8bf68b1acdcf0185

Unhandled exception. System.InvalidOperationException: The examined position must be greater than or equal to the consumed position.
   at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_InvalidExaminedOrConsumedPosition()
   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 Bedrock.Framework.Protocols.ProtocolReader.DoAsyncRead[TReadMessage](Nullable`1 maximumMessageSize, IMessageReader`1 reader, CancellationToken cancellationToken) in C:\code\BedrockFramework\src\Bedrock.Framework\Protocols\ProtocolReader.cs:line 113

Drawaes avatar Jan 26 '20 07:01 Drawaes

I also get this:

This exception was originally thrown at this call stack:
	System.ThrowHelper.ThrowInvalidOperationException_EndPositionNotReached()
	System.Buffers.SequenceReader<T>.IsNextSlow(System.ReadOnlySpan<T>, bool)
	System.Buffers.SequenceReader<T>.TryReadTo(out System.Buffers.ReadOnlySequence<T>, System.ReadOnlySpan<T>, bool)
    Bedrock.Framework.Protocols.Http1ResponseMessageReader.TryParseMessage(System.Buffers.ReadOnlySequence<byte>, ref System.SequencePosition, ref System.SequencePosition, out System.Net.Http.HttpResponseMessage) in Http1ResponseMessageReader.cs
	Bedrock.Framework.Protocols.Http1ResponseMessageReader.Bedrock.Framework.Protocols.IMessageReader<System.Net.Http.HttpResponseMessage>.TryParseMessage(System.Buffers.ReadOnlySequence<byte>, ref System.SequencePosition, ref System.SequencePosition, out System.Net.Http.HttpResponseMessage)
    Bedrock.Framework.Protocols.ProtocolReader.TryParseMessage<TReadMessage>(int?, Bedrock.Framework.Protocols.IMessageReader<TReadMessage>, System.Buffers.ReadOnlySequence<byte>, out TReadMessage) in ProtocolReader.cs
    Bedrock.Framework.Protocols.ProtocolReader.DoAsyncRead<TReadMessage>(int?, Bedrock.Framework.Protocols.IMessageReader<TReadMessage>, System.Threading.CancellationToken) in ProtocolReader.cs
	System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
	System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
	System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
...

davidfowl avatar Jan 26 '20 08:01 davidfowl

Yes I have seen that one also (the next is slow jogged my memory).

Drawaes avatar Jan 26 '20 08:01 Drawaes