在Heroku上出现零星的“ http:代理错误:读取tcp:I / O超时”

时间:2018-12-27 20:37:46

标签: go heroku reverse-proxy

我偶尔在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 

有人知道怎么了吗?

1 个答案:

答案 0 :(得分:1)

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

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

“我的服务”一侧的路由器记录499,因此该应用记录400。

您的代码没有错。使用您的Web服务的外部客户端会提早断开其连接,这就是应用程序在日志中做出响应的方式