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

net/http/httputil: ReverseProxy - websocket connections cannot be canceled #35559

Open
piec opened this issue Nov 13, 2019 · 1 comment
Milestone

Comments

@piec
Copy link

@piec piec commented Nov 13, 2019

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

$ go version
go version go1.13.4 linux/amd64

(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 Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pierre/.cache/go-build"
GOENV="/home/pierre/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pierre/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build415071953=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  • I used httputil.NewSingleHostReverseProxy to create a proxy to a backend server which serves websockets.
  • I made a request to a backend websocket service through the proxy. The request is cancelable using context.WithCancel(...).
  • I canceled the request

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

@andybons andybons added this to the Unplanned milestone Nov 13, 2019
@andybons

This comment has been minimized.

Copy link
Member

@andybons andybons commented Nov 13, 2019

@bradfitz bradfitz modified the milestones: Unplanned, Go1.15 Nov 13, 2019
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.