-
Notifications
You must be signed in to change notification settings - Fork 863
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
HttpForwarder throw exception when trying to forward a POST request. #1665
Comments
Triage:
|
Thanks @DeepWaterWhale. I've filed dotnet/aspnetcore#41305 to fix this in asp.net 6 and 7. We'll disable zero-byte reads in YARP for earlier runtime versions. Which version of asp.net are you using? Working around this would require wrapping the request body stream and having zero-byte reads no-op. |
Related: #1657 |
@Tratcher I am using asp.net 6.0 |
Fixed by #1666 |
Is there a work-around for .net 6.0? I'm having this exact issue while attempting basic direct forwarding and it's blocking any POST request I'm trying to forward. Using YARP 1.1.0. |
Rollback to 1.0 until ASP.NET gets fixed? |
Or if you are not bound to HttpSys, Kestrel is not affected by this issue. |
Rolling back to 1.0 just causes the forwarder to timeout. At least with 1.1.0 it returns an error (ForwarderError.RequestBodyClient) with the following exceptions.
|
If you are seeing such problems with YARP 1.0, it's not the same issue. |
Yep we are reading the request which is injected into a controller method and is required by Swagger to recognize the request model. When removing that parameter I can successfully forward the request, but then we lose Swagger support. Thanks for the help. |
Describe the bug
HttpForwarder throw exception when trying to forward a POST request.
To Reproduce
Forward any POST request with body can repro.
Got Exceptions? Include both the message and the stack trace
Error Message: (Parameter 'size') Actual value was 0.
CallStack:
at Microsoft.AspNetCore.Server.HttpSys.RequestStream.ValidateReadBuffer(Byte[] buffer, Int32 offset, Int32 size)
at Microsoft.AspNetCore.Server.HttpSys.RequestStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 size, CancellationToken cancellationToken)
at System.IO.Stream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
at Yarp.ReverseProxy.Forwarder.StreamCopier.d__3.MoveNext() in D:_GItRepo_\reverse-proxy\src\ReverseProxy\Forwarder\StreamCopier.cs:line 53
-->
Further technical details
Include the version of the packages you are using
Use the latest source code to build the package and testing.
commit id is: b8a58a6
The platform (Linux/macOS/Windows): Windows
I took a look at the code, in my understanding, yarp create a StreamCopyHttpContent in the proxy request to copy the original request's body.
And in StreamCopyHttpContent, it uses StreamCopier to do the real copy work, code is like below. But it throws exception when use an empty buffer directly, then return RequestBodyClient error back.
The text was updated successfully, but these errors were encountered: