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 dialing IPv6 literal hostnames without ports #18248

Closed
sajal opened this issue Dec 8, 2016 · 5 comments
Closed

x/net/http2: error dialing IPv6 literal hostnames without ports #18248

sajal opened this issue Dec 8, 2016 · 5 comments

Comments

@sajal
Copy link

sajal commented Dec 8, 2016

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

go version go1.7.4 linux/amd64

Same behavior on 1.7

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/sajal/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build245028891=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

We are doing something custom with the http package, this issue might not be relevant for common use cases...

Our issue: turbobytes/pulse#5
Example reproduce code: https://gist.github.com/sajal/1e052792023b0a8ff04eba77deeab487

GODEBUG=http2debug=1 go run pilse-5.go --ssl --host="www.cloudflare.com" --endpoint="[2400:cb00:2048:1::c629:d7a2]"
GODEBUG=http2debug=1 run pilse-5.go --ssl --host="dyn.com" --endpoint="[2600:2001:0:3::106]"

First one fails(h2 enabled website), second one works(non-h2 site).

We are using http package along with the awesome httptrace to run some custom tests, to get timing information.

Our terminology :-

  1. host : This is value of the Host request header as well as the ServerName for TLS handshake when accessing over https
  2. endpoint : This is the server we connect to, can be a hostname, IPv4 or IPv6
  3. path: The path being accessed.

The above issue only happens if :-

  1. The website is being accessed using explicit IPv6 endpoint and not a hostname.
  2. The website supports h2

What did you expect to see?

A successful http response. Or at least some err. At worst timeouts being honored.

What did you see instead?

Infinite loop of following messages, and client not respecting timeouts configured.

2016/12/08 23:54:02 https://[2400:cb00:2048:1::c629:d7a2]/
2016/12/08 23:54:02 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available
2016/12/08 23:54:02 0 ConnectStart:  tcp [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:02 61 ConnectDone:  tcp [2400:cb00:2048:1::c629:d7a2]:443 <nil>
2016/12/08 23:54:02 http2: Transport creating client conn 0xc420082000 to [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:02 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available
2016/12/08 23:54:02 459 ConnectStart:  tcp [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:02 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=128, INITIAL_WINDOW_SIZE=65536, MAX_FRAME_SIZE=16777215
2016/12/08 23:54:02 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=2147418112
2016/12/08 23:54:02 509 ConnectDone:  tcp [2400:cb00:2048:1::c629:d7a2]:443 <nil>
2016/12/08 23:54:02 http2: Transport received SETTINGS flags=ACK len=0
2016/12/08 23:54:03 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available
2016/12/08 23:54:03 707 ConnectStart:  tcp [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:03 758 ConnectDone:  tcp [2400:cb00:2048:1::c629:d7a2]:443 <nil>
2016/12/08 23:54:03 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available
2016/12/08 23:54:03 954 ConnectStart:  tcp [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:03 1008 ConnectDone:  tcp [2400:cb00:2048:1::c629:d7a2]:443 <nil>
2016/12/08 23:54:03 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available
2016/12/08 23:54:03 1209 ConnectStart:  tcp [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:03 1257 ConnectDone:  tcp [2400:cb00:2048:1::c629:d7a2]:443 <nil>
2016/12/08 23:54:03 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available
2016/12/08 23:54:03 1442 ConnectStart:  tcp [2400:cb00:2048:1::c629:d7a2]:443
2016/12/08 23:54:03 1494 ConnectDone:  tcp [2400:cb00:2048:1::c629:d7a2]:443 <nil>
2016/12/08 23:54:04 http2: Transport failed to get client conn for [[2400:cb00:2048:1::c629:d7a2]]:443: http2: no cached connection was available

And goes on like this for what seems like forever...

PS: I think the custom Resolver in tip might help me do what I'm doing in a more elegant manner. I have yet to try it out.

@sajal
Copy link
Author

sajal commented Dec 8, 2016

I have a hunch this is from https://golang.org/src/net/http/h2_bundle.go#L5143

https://play.golang.org/p/I4HIN5LMC4

net.JoinHostPort("[2400:cb00:2048:1::c629:d7a2]", "443") returns [[2400:cb00:2048:1::c629:d7a2]]:443 instead of [2400:cb00:2048:1::c629:d7a2]:443 which could be the cause of this issue?

When running my code with following arguments:-

GODEBUG=http2debug=1 go run pilse-5.go --ssl --host="www.cloudflare.com" --endpoint="[2400:cb00:2048:1::c629:d7a2]:443"

It works as expected.

@bradfitz
Copy link
Contributor

bradfitz commented Dec 8, 2016

Thanks. Looks like authorityAddr does have a problem. Sending a fix now.

There are a few unrelated suspicious things in your https://gist.github.com/sajal/1e052792023b0a8ff04eba77deeab487 code, but we can address those separately.

@bradfitz bradfitz self-assigned this Dec 8, 2016
@bradfitz bradfitz changed the title http2: no cached connection was available - infinite loop x/net/http2: error dialing IPv6 literal hostnames without ports Dec 8, 2016
@gopherbot
Copy link

CL https://golang.org/cl/34143 mentions this issue.

@sajal
Copy link
Author

sajal commented Dec 9, 2016

Thanks @bradfitz . Would appreciate feedback in the gist :)

@gopherbot
Copy link

CL https://golang.org/cl/34495 mentions this issue.

gopherbot pushed a commit that referenced this issue Dec 15, 2016
Updates bundled x/net/http2 to git rev 1195a05d for:

    http2: fix incorrect panic
    https://golang.org/cl/34498

    http2: fix race in writePushPromise
    https://golang.org/cl/34493

    http2: speed up TestTransportFlowControl in short mode
    https://golang.org/cl/33241

    http2: don't flush a stream's write queue in sc.resetStream
    https://golang.org/cl/34238

    http2: allow Transport to connect to https://[v6literal]/ without port
    https://golang.org/cl/34143

    http2: log Framer reads and writes when a server test fails
    https://golang.org/cl/34130

Updates #18326
Updates #18273
Updates #18111
Updates #18248
Updates #18235

Change-Id: I18c7a297fc94d6a843284efcfc43e0fdab9b5f41
Reviewed-on: https://go-review.googlesource.com/34495
Run-TryBot: Chris Broadfoot <cbro@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Dec 15, 2017
c3mb0 pushed a commit to c3mb0/net that referenced this issue Apr 2, 2018
Fixes golang/go#18248

Change-Id: I271fbcc68a86f20c57b258c2e25788908dafdd94
Reviewed-on: https://go-review.googlesource.com/34143
Reviewed-by: Tom Bergan <tombergan@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants