Skip to content

HTTP2: Hang when writing sending large data to completed request #30293

Closed

Description

@JamesNK

Writing large data to the request stream (Http2WriteStream retrieved from SerializeToStreamAsync) will hang if the server has finished. I would have expected Stream.WriteAsync to error.

Repro:

  1. git clone https://github.com/JamesNK/grpc-dotnet.git
  2. git checkout jamesnk/unimplemented-duplexstream
  3. dotnet test test\FunctionalTests --filter Name~DuplexStream_SendToUnimplementedMethod_Hang

Logic in the test is like:

  1. Client makes HTTP/2 call to the server
  2. Client immediately starts writing 64 KB to request stream
  3. Server finishes response with 200. It never reads the request stream.
  4. Client's first write of 64 KB succeeds (i.e. doesn't hang. I don't know what has happened to the data). Client writes another block of 64 KB. Client hangs on awaiting Stream.WriteAsync.
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview8-013248
 Commit:    135af55c46

Activity

  1. stephentoub commented on Jul 18, 2019

    @stephentoub
    Member

    It never reads the request stream.

    Isn't that the bug here?

  2. JamesNK commented on Jul 18, 2019

    @JamesNK
    MemberAuthor

    Does a server always have to read the client request to prevent the client from hanging?

    In this scenario the client has called the wrong location and the server sends them a simple status - HEADERS - saying so, followed by RST_STREAM (NO_ERROR). It ignores the request body because there is no reason to read it.

  3. JamesNK commented on Jul 18, 2019

    @JamesNK
    MemberAuthor
    1. Client sends request headers (plus some data straight away)
    2. Client sends more data
    3. Server responds with response headers and stream reset

    image

    I would have thought that if the client is hanging on Http2WriteStream.WriteAsync that it would error when the server sends a stream reset.

  4. stephentoub commented on Jul 18, 2019

    @stephentoub
    Member

    followed by RST_STREAM

    Ah, that wasn't in the original description. If the server is sending RST_STREAM, then yes, the client should stop.

  5. stephentoub commented on Jul 18, 2019

    @stephentoub
    Member

    Same issue?

    Yes, if the issue is that the client isn't respecting RST_STREAM while sending the request body, that's the same issue.

  6. transferred this issue fromdotnet/corefxon Feb 1, 2020
  7. added this to the 3.0 milestone on Feb 1, 2020
  8. ghost locked as resolved and limited conversation to collaborators on Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions