I have made a very simple node server using Fastify. I want to try to use HTTP2. I have followed the docs, and created the server like this:
const fastify = Fastify({ http2: true });
But if I run it and then try to make a request using curl
:
curl -kvso --http2 http://0.0.0.0:3000/health -H "Accept: application/json" -H "Content-type: application/json" --output response.json
It seems the request goes fine but I cannot the what the server is returning:
* Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to 0.0.0.0 (127.0.0.1) port 3000 (#0)
> GET /health HTTP/1.1
> Host: 0.0.0.0:3000
> User-Agent: curl/7.64.1
> Accept: application/json
> Content-type: application/json
>
{ [9 bytes data]
* Closing connection 0
And the JSON contains binary data so I cannot see it. Any idea what's happening?
Update
I have changed the command according to the comments. Now the requests is made using HTTP/2.0 but the commands gets stuck without printing anything:
curl --http2-prior-knowledge --insecure --verbose http://0.0.0.0:3000/health -H "Accept: application/json" -H "Content-type: application/json"
Output:
* Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to 0.0.0.0 (127.0.0.1) port 3000 (#0)
* Using HTTP2, server supports multi-use
* 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 0x7fdc0000f800)
> GET /health HTTP/2
> Host: 0.0.0.0:3000
> User-Agent: curl/7.64.1
> Accept: application/json
> Content-type: application/json
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 4294967295)!