【发布时间】:2021-03-25 03:56:51
【问题描述】:
我在 Heroku 上遇到了神秘的 H18 错误。这些请求似乎是由在我的应用程序的根 URL 上发送 POST 请求的机器人或爬虫发出的。我担心的是,这些请求在被终止之前都需要超过 30 秒的时间来处理,很可能是超时。这是我的日志文件和指标图的示例:
Dec 14 03:52:26 poll-en heroku/router sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/" host=app.do request_id=72252a6a-d4b5-4ecc-ae3c-bc69c273eb16 fwd="138.201.76.138" dyno=web.1 connect=1ms service=30034ms status=503 bytes=71 protocol=http
Dec 14 04:05:11 poll-en heroku/router sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/" host=app.do request_id=78ea5ae4-9e8a-4c90-b26e-c2eae40116b4 fwd="148.251.231.105" dyno=web.1 connect=0ms service=31392ms status=503 bytes=71 protocol=http
Dec 14 04:19:07 poll-en heroku/router sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/" host=app.do request_id=bcc76545-24e0-4fc7-8e63-a08bb463bb31 fwd="148.251.231.105" dyno=web.1 connect=0ms service=30195ms status=503 bytes=71 protocol=http
Dec 14 04:45:35 poll-en heroku/router sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/" host=app.do request_id=87efe086-9879-4506-a7ac-52504219126d fwd="144.76.141.230" dyno=web.1 connect=0ms service=31733ms status=503 bytes=71 protocol=http
我的应用程序不处理根 URL 上的 POST 请求,我无法使用 cURL 复制错误。可以肯定的是,我还添加了一个机架中间件,它首先运行并终止根 URL 上的所有 POST 请求。所以请求甚至不应该到达 Rails 路由器,但我的日志文件中仍然出现这些 H18 错误。
怎么会这样?什么样的请求甚至没有到达我的应用程序时可能会挂起 30 秒?
【问题讨论】:
-
您的应用允许
http请求还是仅允许https?我看到请求在请求http时需要很长时间才能超时,但该应用仅使用https并且重定向存在一些挂断。 -
我设置了
config.force_ssl = true所以http请求被重定向到https。我也在用 cURL 测试这个 http 请求,它会立即返回。这是一个真正的难题! -
@RockwellRice 我想你可能正在做点什么。您是否能够更改配置来解决此问题?
-
不,在我们的例子中是 DNS 问题。
标签: ruby-on-rails heroku puma