【问题标题】:Getting sporadic "http: proxy error: read tcp: i/o timeout" on Heroku [closed]在 Heroku 上获取零星的“http:代理错误:读取 tcp:i/o 超时”[关闭]
【发布时间】:2019-05-25 19:28:18
【问题描述】:

我在 Heroku 上偶尔会收到此错误:

代理服务:

Dec 27 14:53:05 betalo-turnpike-production app/web.2:  { [...] } 

Dec 27 14:53:08 my-proxy app/web.2:  {
    "level":"error",
    "ts":"2018-12-27T14:53:07.771Z",
    "caller":"httputil/reverseproxy.go:393","msg":"http: proxy error: read tcp [REDACTED]->[REDACTED]: i/o timeout",
    "stacktrace":"log.(*Logger).Output

    /app/tmp/cache/go1.11.4/go/src/log/log.go:172
log.(*Logger).Printf
    /app/tmp/cache/go1.11.4/go/src/log/log.go:179
net/http/httputil.(*ReverseProxy).logf
    /app/tmp/cache/go1.11.4/go/src/net/http/httputil/reverseproxy.go:393
net/http/httputil.(*ReverseProxy).defaultErrorHandler
    /app/tmp/cache/go1.11.4/go/src/net/http/httputil/reverseproxy.go:158
net/http/httputil.(*ReverseProxy).defaultErrorHandler-fm
    /app/tmp/cache/go1.11.4/go/src/net/http/httputil/reverseproxy.go:166
net/http/httputil.(*ReverseProxy).ServeHTTP
    /app/tmp/cache/go1.11.4/go/src/net/http/httputil/reverseproxy.go:234
net/http/httputil.(*ReverseProxy).ServeHTTP-fm
    [...]
net/http.HandlerFunc.ServeHTTP
    /app/tmp/cache/go1.11.4/go/src/net/http/server.go:1964
net/http.serverHandler.ServeHTTP
    /app/tmp/cache/go1.11.4/go/src/net/http/server.go:2741
net/http.(*conn).serve
    /app/tmp/cache/go1.11.4/go/src/net/http/server.go:1847"} 

Dec 27 14:53:08 my-proxy app/web.2:  { [...] "status":502} 

Dec 27 14:53:09 my-proxy heroku/router:  sock=backend at=error code=H18 desc="Server Request Interrupted" [...] dyno=web.2 connect=0ms service=4453ms status=503 protocol=https 

调用的服务:

Dec 27 14:53:05 my-service app/web.1:  { [...] } 
Dec 27 14:53:08 my-service app/web.1:  { [...] "status":400} 
Dec 27 14:53:08 my-service heroku/router:  sock=client at=warning code=H27 desc="Client Request Interrupted" [...] dyno=web.1 connect=1ms service=2995ms status=499 bytes=0 protocol=https 

有谁知道怎么回事?

【问题讨论】:

  • 寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及重现它所需的最短代码 在问题本身中。 请参阅 SO Help 上的 Minimal, Complete, Verifiable Example

标签: go heroku reverse-proxy


【解决方案1】:

在外部,我的代理返回 502(上游消失) 我的代理与我的服务对话,返回 400(客户端错误) 路由器层返回499(客户端关闭请求)

发生的事情是外部调用者正在断开连接,而“我的服务”正在准备返回连接的结果 到“我的代理”。这意味着套接字从“我的代理”端删除。

我的服务端的路由器记录了 499,因此应用记录了 400

您的代码没有任何问题。使用您的 Web 服务的外部客户端会提前断开连接,这就是应用程序在日志中响应的方式

【讨论】:

  • 感谢您的评论!我开始意识到客户端丢弃请求是正常行为,因此服务器能够优雅地处理它。令我恼火的是我的代理似乎能够在这方面失败的不同(可记录)方式的数量:context cancelednet/http: request canceledunexpected EOFhttp: proxy error: read tcp [...]->[...]: i/o timeout。您是否看到类似的行为?也许这只是表示请求被取消的不同时间点。
  • 我在与 heroku 完全不同类型的系统上看到了这个问题。问题是前端如何响应外部客户端的离开?如果前端断开与后端的连接,则将发生此响应代码序列。通常,这些错误无关紧要
猜你喜欢
  • 2018-08-16
  • 2016-04-03
  • 2021-09-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-22
相关资源
最近更新 更多