Skip to content
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

Cancellation can leave an HTTP/1.x connection in half-closed state #2264

Merged
merged 3 commits into from
Jul 18, 2022

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Jul 8, 2022

Motivation:

If a response is canceled at the connection level (skipping explicit
closure of the connection in LoadBalancedStreamingHttpClient), it will
hang in a half-closed state (inbound closed) if the server doesn't proceed
with sending more bytes on that connection (outbound will never be
closed). Also, cancellation marks the connection as
CHANNEL_CLOSED_INBOUND, which is misleading because the closure is
initiated by the client.

Modifications:

  • Enhance ResponseCancelTest to verify the described scenario;
  • Adjust NettyChannelPublisher to close both outbound (first, to
    correctly mark the connection close reason) and inbound;

Result:

Canceled HTTP/1.x connection is always closed correctly.

Motivation:

If a response is cancelled at the connection level (skipping explicit
closure of the connection in `LoadBalancedStreamingHttpClient`), it will
hang in half-closed state (inbound closed) if the server doesn't proceed
with sending more bytes on that connection (outbound will never be
closed). Also, cancellation marks the connection as
`CHANNEL_CLOSED_INBOUND`, which is misleading because the closure is
initiated by the client.

Modifications:

- Enhance `ResponseCancelTest` to verify the described scenario;
- Adjust `NettyChannelPublisher` to close both outbound (first, to
correctly mark the connection close reason) and inbound;

Result:

Cancelled HTTP/1.x connection is always closed correctly.
@idelpivnitskiy idelpivnitskiy requested a review from Scottmitch July 8, 2022 21:16
@idelpivnitskiy idelpivnitskiy self-assigned this Jul 8, 2022
@idelpivnitskiy idelpivnitskiy merged commit c4b13e9 into apple:main Jul 18, 2022
@idelpivnitskiy idelpivnitskiy deleted the NettyChannelPublisher branch July 18, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants