【问题标题】:Golang: http2 and TLS handshake errorsGolang:http2 和 TLS 握手错误
【发布时间】:2017-01-25 15:00:49
【问题描述】:

我有一个启用了 http(端口 80)和 https(端口 443)的 Go 应用程序。

我不断收到很多这 3 种错误:

  • http2: server: error reading preface from client 79.49.31.60:37993: timeout waiting for client preface

  • http: TLS handshake error from 151.38.29.250:44235: EOF

  • http: TLS handshake error from 2.239.197.163:6742: read tcp x.xxx.xxx.xxx:443->2.239.197.163:6742: i/o timeout

谁能解释一下这些指的是什么?

请注意:所有这些请求都来自移动浏览器(在 Android 和 iOS 设备上)

【问题讨论】:

  • 如果这些客户不是您的,请忽略它们。表现不佳的客户端、超时和 Internet 断开连接并不是什么新鲜事或意外。

标签: ssl go https http2 sslhandshakeexception


【解决方案1】:
http2: server: error reading preface from client 79.49.31.60:37993: timeout waiting for client preface

这意味着客户端在服务器超时之前未能发送http2连接前言(https://www.rfc-editor.org/rfc/rfc7540#section-3.5)。

http: TLS handshake error from 151.38.29.250:44235: EOF

这意味着当服务器和客户端执行 TLS 握手时,服务器看到连接被关闭,也就是 EOF。

http: TLS handshake error from 2.239.197.163:6742: read tcp x.xxx.xxx.xxx:443->2.239.197.163:6742: i/o timeout

这意味着当服务器在 TLS 握手期间等待从客户端读取数据时,客户端在关闭连接之前没有发送任何内容。

正如@JimB 指出的那样,这些是完全正常的。如果您认为超时时间过早,您可以通过定义自定义net.http.Transport: https://golang.org/pkg/net/http/#Transport 来定义自定义超时,并为超时设置更高的值。

【讨论】:

  • Frederik,感谢您的宝贵解释。考虑到所有这些请求都来自移动浏览器(在 Android 和 iOS 设备上),您是否看到一些具体原因?非常感谢
  • 是的,移动连接往往具有更高的 RTT、更低的带宽和更多的丢包率。
  • 当用户的互联网连接太慢并且应用程序构建太大时,这些错误会更频繁地弹出。
猜你喜欢
  • 2016-03-21
  • 2014-12-09
  • 2017-01-17
  • 1970-01-01
  • 2021-06-16
  • 2021-11-13
  • 2020-10-11
  • 2020-07-03
  • 2013-05-17
相关资源
最近更新 更多