HTTP2 With Prior Knowledge: Broken Pipe

Hello,

I am creating an app that will need to accept http2 over plain text (h2c). I want to support both http2 and http2-prior-knowledge. I’ve created a small GO application to test this, however, when I try to connect with http-prior-knowledge I get a broken pipe error.

❯ curl --http2-prior-knowledge http://h2c-test.fly.dev -v
*   Trying 66.241.125.209:80...
* Connected to h2c-test.fly.dev (66.241.125.209) port 80 (#0)
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x134811400)
> GET / HTTP/2
> Host: h2c-test.fly.dev
> user-agent: curl/7.79.1
> accept: */*
>
* Recv failure: Connection reset by peer
* Failed receiving HTTP2 data
* Send failure: Broken pipe
* Failed sending HTTP2 data
* Connection #0 to host h2c-test.fly.dev left intact
curl: (56) Recv failure: Connection reset by peer

I have set the app up according to this:

Here is my current configuration:

# fly.toml
app = 'h2c-test'
primary_region = 'mia'

[build]
builder = 'paketobuildpacks/builder:base'
buildpacks = ['gcr.io/paketo-buildpacks/go']

[env]
PORT = '8080'

[http_service]
internal_port = 8080
force_https = false
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[http_service.http_options]
h2_backend = true

Am I doing anything wrong here to prevent being able to accept http2 requests with prior knowledge?

Hey @jlemrond

Currently, h2c doesn’t work over shared IP addresses. When fly-proxy receives a request to a shared IP address it needs to find out which app to route this request to. In case of TLS it uses SNI, but in case of plain HTTP requests it has to parse the headers to extract the hostname. The parser that we use on edge to do this supports only HTTP/1.

This should work if you use https://h2c-test.fly.dev. fly-proxy will terminate TLS and with the h2_backend setting set to true your app will receive an h2c request.

Is there a particular reason why you need to send clear-text HTTP/2 requests?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.