From c6bdce55b57f6f15c567b96160fa7147ded089c9 Mon Sep 17 00:00:00 2001 From: Germano Eichenberg Date: Tue, 12 Apr 2022 20:55:59 -0300 Subject: [PATCH] Disable http2, take 2 --- lib/discord.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/discord.go b/lib/discord.go index caf0ff2..6ebb3c0 100644 --- a/lib/discord.go +++ b/lib/discord.go @@ -31,7 +31,20 @@ type BotUserResponse struct { func createTransport(ip string) http.RoundTripper { if ip == "" { - return http.DefaultTransport + // http.DefaultTransport options, with http2 disabled + return &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).DialContext, + ForceAttemptHTTP2: false, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + TLSNextProto: map[string]func(string, *tls.Conn) http.RoundTripper{}, + } } addr, err := net.ResolveTCPAddr("tcp", ip+":0") @@ -55,7 +68,7 @@ func createTransport(ip string) http.RoundTripper { } transport := http.Transport{ - ForceAttemptHTTP2: true, + ForceAttemptHTTP2: false, MaxIdleConns: 1000, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second,