Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/http2: error message is unclear when connecting to an http 1.x server #35724

Open
jingyugao opened this issue Nov 21, 2019 · 3 comments
Milestone

Comments

@jingyugao
Copy link

@jingyugao jingyugao commented Nov 21, 2019

What version of Go are you using (go version)?

1.13

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"

What did you do?

https://play.studygolang.com/p/_1kMO-E_FEq
I use an http2 client try to connect an http client.

I expect to see an protocol error or somethig that can tell me the destination is not a valiad http2 service.

What did you see instead?

I get an "unexpected EOF" error.
I think we can make the error more clearly.

According to the rfc, the last segment of [https://httpwg.org/specs/rfc7540.html#rfc.section.3.5]

Clients and servers MUST treat an invalid connection preface as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

It seems we should return PROTOCOL_ERROR

@jingyugao jingyugao changed the title how about return a more clearly error when http2 client try to connect some services that are not http2 server. x/net/http2: how about return a more clearly error when http2 client try to connect some services that are not http2 server. Nov 21, 2019
@toothrot toothrot changed the title x/net/http2: how about return a more clearly error when http2 client try to connect some services that are not http2 server. x/net/http2: error message is unclear when connecting to a http 1.x server Nov 22, 2019
@toothrot toothrot changed the title x/net/http2: error message is unclear when connecting to a http 1.x server x/net/http2: error message is unclear when connecting to an http 1.x server Nov 22, 2019
@toothrot toothrot added this to the Backlog milestone Nov 22, 2019
@toothrot

This comment has been minimized.

Copy link
Contributor

@toothrot toothrot commented Nov 22, 2019

/cc @bradfitz @tombergan who own net/http2

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Nov 22, 2019

Yeah, I saw the associated CL earlier (which had no context) and I asked for this bug to be filed.

This doesn't affect normal net/http or x/net/http2 users. This affects people using the low-level http2.Framer directly, writing their own HTTP/2 clients.

@jingyugao

This comment has been minimized.

Copy link
Author

@jingyugao jingyugao commented Nov 25, 2019

Client base on http2 may wrap the error and return an "http2:unexpected EOF" to users. Users cant know why.If client set the maxReadSize, users may get and "http2: frame too large" error.
Both error cant tell user the real reason.
If we first check the frame type, we can return the exact error and we don't need to read the last content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.