登录
首页 >  Golang >  Go问答

在Heroku上发生间歇性的“http: 代理错误:读取tcp: i/o 超时”

来源:stackoverflow

时间:2024-02-29 18:18:27 393浏览 收藏

你在学习Golang相关的知识吗?本文《在Heroku上发生间歇性的“http: 代理错误:读取tcp: i/o 超时”》,主要介绍的内容就涉及到,如果你想提升自己的开发能力,就不要错过这篇文章,大家要知道编程理论基础和实战操作都是不可或缺的哦!

问题内容

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

谁知道出了什么问题吗?


解决方案


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

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

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

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

今天关于《在Heroku上发生间歇性的“http: 代理错误:读取tcp: i/o 超时”》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于的内容请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>