Skip to content

Commit 25a061f

Browse files
committed
fix(listenbrainz): disable keep-alive to avoid connection reset errors
1 parent 4fff418 commit 25a061f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

listenbrainz/listenbrainz.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ type Client struct {
3030
}
3131

3232
func NewClient() *Client {
33-
return NewClientCustom(http.DefaultClient)
33+
// disable keep-alive to avoid "connection reset by peer" errors caused by a race between
34+
// the server closing idle connections and the client reusing them for new requests
35+
return NewClientCustom(&http.Client{
36+
Transport: &http.Transport{
37+
DisableKeepAlives: true,
38+
},
39+
})
3440
}
3541

3642
func NewClientCustom(httpClient *http.Client) *Client {

0 commit comments

Comments
 (0)