Skip to content

System.ArgumentOutOfRangeException when using test server in combination with Yarp #1720

Closed
@Erwinvandervalk

Description

@Erwinvandervalk

Describe the bug

I'm creating a test server for my application and another testserver for the reverse proxy. When I call the proxy, it should forward the call to the application, but instead, I get the following exception:

System.ArgumentOutOfRangeException

To Reproduce

I've included a test project that gives the error for me.
yarp.zip

Yarp.ReverseProxy.Forwarder.HttpForwarder[48]
      ResponseBodyDestination: The destination reported an error when copying the response body.
      System.ArgumentOutOfRangeException:  (Parameter 'count')
      Actual value was 0.
         at Microsoft.AspNetCore.TestHost.ResponseBodyReaderStream.VerifyBuffer(Byte[] buffer, Int32 offset, Int32 count)
         at Microsoft.AspNetCore.TestHost.ResponseBodyReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
         at Yarp.ReverseProxy.Forwarder.StreamCopier.CopyAsync(Stream input, Stream output, Int64 promisedContentLength, StreamCopierTelemetry telemetry, ActivityCancellationTokenSource activityToken, CancellationToken cancellation)

Further technical details

Yarp 1.1.0
testhost 6.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions