-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/httputil: ReverseProxy - websocket connections cannot be canceled #35559
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
Comments
Thank you for reporting this issue @piec and welcome to the Go project! Apologies foe the late reply, and thanks for the patience. |
Change https://golang.org/cl/224897 mentions this issue: |
@piec please take a look at the feedback that I left on your CL https://go-review.googlesource.com/c/go/+/224897#message-f3370368c9bfcf1cf91be57337ec9689b9a799ae, it would be great to get this in before the code freeze which is in 4 weeks. Thank you! |
Yes I took a look at the review @odeke-em, and thank you for it. |
… cancelable Ensures that a canceled client request for Switching Protocols (e.g. h2c, Websockets) will cause the underlying connection to be terminated. Adds a goroutine in handleUpgradeResponse in order to select on the incoming client request's context and appropriately cancel it. Fixes golang#35559 Change-Id: I1238e18fd4cce457f034f78d9cdce0e7f93b8bf6 GitHub-Last-Rev: 3629c78 GitHub-Pull-Request: golang#38021 Reviewed-on: https://go-review.googlesource.com/c/go/+/224897 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
What version of Go are you using (
go version
)?(also checked master)
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Up to date Arch Linux amd64
go env
OutputWhat did you do?
httputil.NewSingleHostReverseProxy
to create a proxy to a backend server which serves websockets.context.WithCancel(...)
.What did you expect to see?
I expected the reverse proxy to close the connection to the backend server.
What did you see instead?
The connection between the reverse proxy and the backend server was preserved.
Hi All,
I quickly modified the
TestReverseProxyWebSocket
test to reproduce my issue eshard@73147b8 (I modified TestReverseProxyWebSocket in place to make the diff more readable)I also did a dirty fix: eshard@98e746e which propagates the cancelation to the
handleUpgradeResponse
function. It creates an additional goroutine so it's not ideal.I'd be happy to improve my patch with your inputs
Best regards
Pierre
The text was updated successfully, but these errors were encountered: