Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
x/net/http2: transport.CloseIdleConnections() does not have any effect #14607
I'm writing a service that delivers notifications to Apple's APNS service via their HTTP/2 API. For some reason APNS stops caring about an HTTP/2 connection after a certain amount of time of idling. The problem is that HTTP/2 connections are retained in the client pool, and they eventually become unusable because they are 100% guaranteed to time out once APNS stops caring about them. Despite this, they're not removed from the HTTP/2 client pool which means my service is rendered unusable.
Initially I was thinking of keeping the connection alive by pinging, but I'm unable to find a way to send PING frames with the Go HTTP library, so what I tried to do instead is to kill idle connections and reestablish them later (since this should be a fairly rare occurrence anyway). However, it appears that calling
(Note that using an invalid device token in this example is intentional.)
I've investigated this further and when running a Docker instance on my computer (MacBook Pro) I can't reproduce the timeout issue, but it does occur regularly on my Kubernetes pod (on Google Container Engine), so it's probably because the Go sockets can't detect that they've been shut down by Google Cloud's keep-alive timeout of 10 minutes.
Something is still not right with
I've attached the full set of logs (kubelogs.txt) from my Kubernetes pod showing how requests work and then after a while start failing with timeouts (the
While this issue is for
…together Go 1.6+ wires up its http.Transport values to http2 with ConfigureTransport. ConfigureTransport sets the connection pool to a "noDialClientConnPool" type. But the Transport.CloseIdleConnections implementation was specifically looking for a concrete type. Look for an interface instead. Updates golang/go#14607 (needs bundle into the main repo before fix) Change-Id: I6ad23b6facab5d3c2cbe71a1809a52794375d803 Reviewed-on: https://go-review.googlesource.com/23258 Run-TryBot: Brad Fitzpatrick <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Andrew Gerrand <firstname.lastname@example.org>