-
Notifications
You must be signed in to change notification settings - Fork 348
Open
Description
Hi! I noticed that creating a new client with default options might lead to an http2 connection leak. I found a handy solution using the IdleConnTimeout option from this helpful Pull Request: golang.org/x/net#170. I was thinking it would be really cool if the library could automatically close these connections by default, or at least give developers a heads-up to use CloseIdleConnections in their code. This would save everyone a bit of trouble and debugging time! What do you think?
| Before | After some time |
|---|---|
![]() |
![]() |
Got this all sorted out on 11/07 with
client := apns2.NewTokenClient(t)
client.HTTPClient.Transport = &http2.Transport{
DialTLS: apns2.DialTLS,
ReadIdleTimeout: apns2.ReadIdleTimeout,
IdleConnTimeout: 90 * time.Second, // handle conn leak
}
- What version of Go are you using?
go version
1.23.2 - What OS and processor architecture are you using?
go env
Linux - amd64 - What did you do?
I used the methodapns2.NewTokenClient()to create new client and usePushWithContext()send a push notification. - What did you expect to see?
The amount of goroutines should reduce over time and return to normal. - What did you see instead?
Goroutines keep increasing under high load due to http2 keeping open new connections without automatically closing them.
txbxxx and nguyentranbao-ct
Metadata
Metadata
Assignees
Labels
No labels

