Skip to content

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

@sajal

Description

@sajal

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions