Skip to content

ASP.NET HTTPS request "hangs" when reading request stream on certain requests #44525

@MarkPflug

Description

@MarkPflug

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In testing a custom input/output formatter that I've developed I encountered what I believe might be a bug in ASP.NET.
Request processing hangs when reading from the request stream (Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsync). This happens when a custom TextInputFormatter binds the request body to an IAsyncEnumerable controller action argument, which causes the reading of the request and the writing of the response to overlap (which is probably unusual). This only happens when the request exceeds a certain size. (NOT the asp.net request size limit).

The issue is best understood with a minimal repro, which is available in this repository: https://github.com/MarkPflug/HttpStreamMinRepro

The repository also includes more detailed description of the issue.

Expected Behavior

The request proceeds without hanging regardless of the request size, assuming it doesn't exceed the asp.net request size limit. Alternately, an exception is thrown informing me that I've done something silly.

Steps To Reproduce

See the minimal repro in the linked repository: https://github.com/MarkPflug/HttpStreamMinRepro

Run the web app, then the ReproClient to generate a large request.

Exceptions (if any)

There isn't really an exception thrown, other than the exception thrown when the client disconnects due to timeout, but that exception isn't an issue.

.NET Version

7.0.100-rc.2.22477.23

Anything else?

This repros on .net 6 as well. Repros on both kestrel and iisexpress. This only seems to happen on HTTPS requests. Over HTTP, the response is properly received. The PlainTextOutputFormatter isn't critical to the repro, it also hangs with the standard JSON output. However, I don't see the server unwind in the debugger when the JSON formatter is used (I can't explain this either).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions