-
Notifications
You must be signed in to change notification settings - Fork 18k
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/h2c: http BaseContext/ConnContext methods are not used #37089
Comments
/cc @bradfitz @tombergan per owners. |
cc @fraenkel re http2 |
@jared2501 One question, now that you have created the context, what is going to use it? |
I was using it in downstream handler code so that I can track the number of HTTP/2 streams that exist per HTTP/2 connection. I.e. I have some code like this:
|
The reason for doing this is that we had an issue in production where a frontend web application was continually opening long-lived server streams, and never closing old streams. We then hit 250 open streams on a few of our HTTP/2 connections, which is the default max number before the |
@jared2501 If you have set the MaxConcurrentStreams, the client side should be getting a stream error. |
One thing to note that I would need the remote address, not just the local address, since the (local, remote) tuple fully identifies the connection. If I had this, then I could also achieve this goal so would also be happy with that solution. |
But you do have the remote address via the Request. |
@fraenkel ah you're totally right! So if I wanted to do this, I guess I could track this using a |
@jared2501 You could use srv.ConnState() to track that, no? |
@fraenkel The trouble is that once the HTTP/2 server takes over the |
Ah I guess you're saying that after the connection ends, the |
If so then yeah that's fine, we can close this ticket out |
we're implementing an auth system which uses ConnContext to extract some per-connection information that is used later for auth purposes:
we'd like to help make this change and have a preliminary patch ready. would that be something folks here would consider? |
Change https://go.dev/cl/419181 mentions this issue: |
Fixes golang/go#37089 Change-Id: I793bf8b420fd7b5a47b45ad1521c5b5f9e0321b2 GitHub-Last-Rev: 805b90e36a9a9986a57de86eb8f6725359f7abfe GitHub-Pull-Request: golang/net#139 Reviewed-on: https://go-review.googlesource.com/c/net/+/419181 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do? What did you expect to see? What did you see instead?
Currently, the
http2/h2c
package does not use thehttp.Server.BaseContext
orhttp.Server.ConnContext
methods. This means if I use the h2c package to upgrade a connection, the context for the user's is inherited from the background context rather than any context returned from theBaseContext
orConnContext
functions.A possible fix would be something like this:
Does this seem reasonable?
The text was updated successfully, but these errors were encountered: