浏览器在发送 POST-body 之前空闲

发布于 2024-12-10 18:15:37 字数 763 浏览 0 评论 0原文

我在网站上发现了一些看似随机的客户的非常有趣的行为。我看到的是,对服务器的随机 POST 请求会导致对后端的错误请求。我已经找到了请求不好的原因 - 但我仍然不知道为什么会发生这种情况。

  1. 客户端通过 HTTP 连接到 Web 服务器。
  2. 客户端发送普通 POST 请求的标头(而不是正文)
  3. 五秒钟过去了。缓存服务器将请求传递到其后端,因为完成请求的时间太长。
  4. 缓存服务器回复客户端,并带有错误消息 - 表明请求是错误的。
  5. 客户端在收到回复后几秒钟发送 POST 正文。

我毫不犹豫地接受缓存服务器可以重新配置以等待更长的时间。我的问题是;客户端在发送标头和发送 POST 正文之间等待几秒钟的原因可能是什么?我不知道这种行为在任何情况下都是有意义的。

这是一个相当普通的 Magento 电子商务网站,设置了 Haproxy ->清漆-> Nginx-> php5-fpm。 Varnish 是当空闲五秒后将请求发送到 Nginx 的组件。

  • 我已经使用 tcpdump/wireshark 验证服务器在规定时间内没有收到来自客户端的 POST-body(在 Haproxy 之前也是如此)。
  • 我已经验证这种情况发生在用户代理和各种请求(普通登录表单,ajax 回调)中,

有人有什么聪明的想法吗?

注意:我不确定这是 Stack Overflow 还是 Serverfault 的问题,但我认为这是一个需要开发人员知识的 HTTP 问题。

I have some very interesting behaviour from seemingly random clients on a website. What I see is that random POST-requests to the server result in a bad request to the backend. I've tracked down why the request is bad - but I still don't know WHY this occurs.

  1. Client connects to webserver with HTTP.
  2. Client sends the headers of an ordinary POST-request (not the body)
  3. Five seconds pass. The cache server passes the request to its backend, because it took too long to complete the request.
  4. The cache server replies to the client, with an error message - indicating that the request was bad.
  5. The client sends the POST-body - a few seconds after the reply has been received.

I have no problem accepting that the cache server can be reconfigured to wait longer. My problem is; What can be the reason for clients to wait several seconds between the headers sent, and sending the POST-body? I don't know of any cases where this behavior makes sense.

This is a fairly ordinary Magento eCommerce website, with a setup of Haproxy -> Varnish -> Nginx -> php5-fpm. Varnish is the component that ships the request to Nginx when five seconds of idling has passed.

  • I have verified with tcpdump/wireshark that the server does not receive the POST-body from the client within the time (before Haproxy as well).
  • I have verified that this occurs across user agents, and across the kind of requests (Being ordinary login forms, to ajax callbacks)

Does anyone have any clever ideas?

NOTE: I wasn't sure if this was a question for Stack Overflow or Serverfault, but I consider this an HTTP question that requires developer-knowledge.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黄昏下泛黄的笔记 2024-12-17 18:15:37

服务器有问题——您不应该将部分请求从前端发送到后端。在传输 POST 正文之前,客户端可能正在等待服务器的 HTTP/100 Continue 响应。客户端也可能正在生成 POST 数据,但由于某种原因花费了一些时间。

The server is buggy-- you shouldn't send partial requests from the front-end to the backend. It's possible that the client is waiting for a HTTP/100 Continue response for the server before transmitting the POST body. It's also possible that the client is generating the POST data and that's taken some time for some reason.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文