关于golang:golang-http11的请求负载均衡按照http20转发问题

要害参数:
TLSNextProto

解决方案:
把TLSNextProto设置成空map,这样就不会主动降级,相当于敞开http2.0

client := &http.Client {
  Transport:&http.Transport{
      TLSNextProto: map[string]func(authority string, c *tls.Conn) http.RoundTripper{},
  },
}

起因:
来自 https://stackoverflow.com/que…
Starting with Go 1.6, the http package has transparent support for the HTTP/2 protocol when using HTTPS. Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) or Server.TLSNextProto (for servers) to a non-nil, empty map. Alternatively, the following GODEBUG environment variables are currently supported:

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理