I'm tryng to use nghttpd server to test HTTP/2.0. To start it i'm using:
sudo nghttpd --push=/test=/test1.png,/test2.pcapng,/test2.txt,/test3.png --no-tls --workers=3 --early-response -v 80.
In my CWD i've got the push files. In another terminal, i type:
telnet localhost 80
And everything seems ok, since i have this output in the first terminal
[id=1] [ 11.893] send SETTINGS frame <length=6, flags=0x00, stream_id=0>
(niv=1)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[id=1] [ 21.898] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=0, error_code=SETTINGS_TIMEOUT(0x04), opaque_data(0)=[])
The problems occur when i try an (any type of) HTTP GET with the second terminal:
telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /test HTTP/2.0
Connection closed by foreign host.
In my first terminal i get this output
[id=1] [314.531] closed
How can i solve this?
Little more elaboration: the HTTP/2 server sends control frames like
MAGIC
andSETTINGS
(this includes information like Max Concurrent Streams and Initial Window Size) and the server does not honor the client until these are acknowledged by the client (in aSETTINGS
frame as well).Telnet just establishes the TCP connection and then waits for the user to issue next packets.
Without seeing these control frames in couple of seconds, the server closes the connection in couple of seconds.
This is in accordance to RFC 7540, section 6.5.3:
This is the log of nghttpd (running in verbose mode) when I connected via Telnet:
In fact, in your question lies the answer, only that you printed the log of nghttpd server in parts. The server sent
GOAWAY
frame 10 seconds after sending theSETTINGS
frame and closed the TCP connection.