h2spec
h2spec copied to clipboard
HTTP2 spec section 3.5 error
it looks like the good folks over at actix-web found an error in h2spec section 3.5
https://github.com/actix/actix-web/issues/1453
"Clients and servers MUST treat an invalid connection preface as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. A GOAWAY frame (Section 6.8) MAY be omitted in this case, since an invalid preface indicates that the peer is not using HTTP/2." per http2 sec https://http2.github.io/http2-spec/#ConnectionHeader
but it looks like h2spec requires a GOAWAY frame--please see the linked issue
Sorry for the delayed response.
h2spec expects a GOAWAY frame OR connection to be disconnected in 3.5. It does not necessarily require a GOAWAY frame.
Looking at the output of the original Issue, it looks like the server is forcing the connection to be terminated without proper disconnection from the server. Is your server side properly terminating the connection?
Hypertext Transfer Protocol Version 2 (HTTP/2)
3. Starting HTTP/2
3.5. HTTP/2 Connection Preface
× 2: Sends invalid connection preface
-> The endpoint MUST terminate the TCP connection.
Expected: GOAWAY Frame (Error Code: PROTOCOL_ERROR)
Connection closed
Actual: Error: read tcp 127.0.0.1:56738->127.0.0.1:8080: read: connection reset by peer
Also at Jetty we are having problems with the too strict interpretation of this section.
Sending an invalid preface may first trigger a HTTP/1.1 parser (in case a HTTP/1.1 to HTTP/2 upgrade is necessary).
The HTTP/1.1 parser will not recognize the preface and generate a HTTP/1.1 400 with a small body, and then close the connection.
Apparently, h2spec does not allow for some bytes before reading -1?
Attached a network capture that shows the issue. h2spec_3.5.pcapng.zip
Thanks!
This issue could most probably be solved by #119
A workaround (kludge) is
--- a/spec/verifier.go
+++ b/spec/verifier.go
@@ -66,6 +66,10 @@ func VerifyConnectionError(conn *Conn, codes ...http2.ErrCode) error {
if actual == nil {
actual = event
}
+ case ErrorEvent:
+ if event.String() == "Error: unexpected EOF" {
+ passed = true
+ }
default:
actual = event
}
#119 addresses the issue more cleanly.
Hi from Payara, both master and #119 still fail on Ubuntu the same way ...
Hypertext Transfer Protocol Version 2 (HTTP/2)
3. Starting HTTP/2
3.5. HTTP/2 Connection Preface
using source address 127.0.0.1:49970
× 2: Sends invalid connection preface
-> The endpoint MUST terminate the TCP connection.
Expected: GOAWAY Frame (Error Code: PROTOCOL_ERROR)
Connection closed
Actual: Error: unexpected EOF
The trick from @gstrauss works, but looks very nasty :-)