GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — No way of having a HTTP2 proxy with a single (outbound/client) TCP connection? · Issue #9296 · netty/netty

No way of having a HTTP2 proxy with a single (outbound/client) TCP connection? #9296

New issue
Copy link
New issue
Copy link
Closed
Closed
No way of having a HTTP2 proxy with a single (outbound/client) TCP connection?#9296
Copy link

Description

@TristanPerry
TristanPerry
opened on Jun 28, 2019
Issue body actions

Overview

I am working on a Netty-powered HTTP2 proxy, meaning that the server will accept HTTP2 frames and forward them on to an outbound 'node', receiving the responses and sending them back to the original 'client'. Until a GOAWAY frame is received, you would expect just a single inbound TCP connection (from the client) and a single outbound TCP connection (to the node) to be open. Hopefully that makes sense, but since a picture is worth 1,000 words etc:

Netty-proxy-question (1)

Expected behavior

On the client (outbound) flow - which is #2/#3 in the diagram above - I would have expected there to be a way for the established TCP connection to be kept open until a GOAWAY frame is received, so that all HTTP2 frames across multiple streamIds will be sendable through the same TCP connection.

Actual behavior (summary)

I have been unable to find a way of doing this (keeping the connection open). DefaultHttp2ConnectionDecoder does the following:

if (endOfStream) {
    lifecycleManager.closeStreamRemote(stream, ctx.newSucceededFuture());
}

meaning that once our outbound-established connection receives a HEADER or DATA frame which is marked as end of stream, the connection is closed. Therefore if there is a subsequent HEADER or DATA inbound frame from the client (for a different streamId), attempting to write this to the outbound node will result in a ClosedChannelException.

In other words:

  1. A HTTP2 request comes in for /test (Build stability fix + .gitignore update #1 in the earlier diagram)
  2. This will be forwarded on (Typo fixes #2), and the HTTP2 response (Add a new faster, memory efficient URL decoder.  #3) is HTML which contains some assets (css/images etc). At this point, the outbound TCP connection (established during Typo fixes #2) is closed by Netty.
  3. The response is sent back to the client (Fix for NETTY-370 #4) via the original inbound TCP connection.
  4. The client sees that there are assets, and sends HEADER frames up (Build stability fix + .gitignore update #1) - with different streamIds - for these. Trying to write these to the outbound (Typo fixes #2) fails with ClosedChannelException because Netty closed the connection earlier.

Code/further explanation

Because of the issue explained above, I am currently creating a new Http2StreamChannel for each new outbound connection - code for this is on a previous Stackoverflow question I asked.

Creating a new connection/Http2StreamChannel naturally works around the original issue, however it obviously means the proxy isn't as efficient because many TCP connections are opened/closed on the outbound.

So I'm guessing that either:

  1. My linked code on SO is wrong and I'm creating new connections when there is an alternative/better way of approaching this

or:

  1. There needs to be a way of keeping Http2MultiplexCodec/Http2FrameCodec-powered connections open even after an end of stream frame is received?

Activity

  1. TristanPerry commented on Jul 1, 2019

    @TristanPerry
    TristanPerry
    on Jul 1, 2019
    ContributorAuthor
    More actions

    So I'm guessing that either:

    1. My linked code on SO is wrong and I'm creating new connections when there is an alternative/better way of approaching this
      or:
    2. There needs to be a way of keeping Http2MultiplexCodec/Http2FrameCodec-powered connections open even after an end of stream frame is received?

    It was option 1 after all - I was incorrectly assuming that a new Channel was needed each time that Http2StreamChannelBootstrap/Http2StreamChannel was used; I hadn't realised that the latter classes are more like wrappers and thus an existing Channel can be used for them.

  2. TristanPerry
    closed this as completedon Jul 1, 2019
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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.