为什么用户代理在服务器进行TCP重置后重新提交请求? [英] Why does the user agent resubmit a request after server does a TCP reset?

查看:202
本文介绍了为什么用户代理在服务器进行TCP重置后重新提交请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近发现了一个问题,其中一些用户代理会重复相同的POST请求,而用户实际上并没有两次触发它。

We've recently noticed a problem where some user agents would repeat the same POST request without the user actually physically triggering it twice.

经过进一步研究,我们注意到了这只发生在请求通过我们的负载均衡器并且服务器花了很长时间处理请求时。数据包捕获会话最终显示负载均衡器在超时5分钟后通过向客户端发送TCP重置来断开连接;但是,客户端会在没有用户干预的情况下自动重新提交请求。

After further study, we noticed this only happens when the request goes through our load balancer and when the server took a long time to process the request. A packet capture session eventually revealed that the load balancer drops the connection after a 5 minute timeout by sending a TCP Reset to the client; however, the client automatically resubmitted the request without user intervention.

我们在Apache HTTP客户端中观察到Java,Firefox和IE 8的这种行为。(我无法安装其他浏览器测试。)这让我觉得这个行为是HTTP标准的一部分,但这对google来说并不是一件容易的事。

We observed this behavior in Apache HTTP client for Java, Firefox and IE 8. (I cannot install other browsers to test.) This makes me think this behavior is part of the HTTP standard, but this is not very easy to google.

此外,似乎这只会在第一次出现时发生请求是通过保持活动的TCP连接提交的。

Also, it seems this only happen if the first request is submitted via a kept-alive TCP connection.

推荐答案

这是处理已关闭连接的HTTP 1.1协议的一部分服务器过早。

This is part of the HTTP 1.1 protocol to handle connections that are closed prematurely by servers.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.4

我经历过类似的情况,我们有相同的表格在几毫秒之内发布了几次。

I experienced a similar situation whereby we had the same form posted a couple of times within milliseconds apart.

通过wireshark的数据包捕获确认了浏览器的重新传输和lo来自服务器的gs表示请求的到达。

A packet capture via wireshark confirmed the retransmission by the browser and logs from the server indicated the arrival of the requests.

此外,进一步的调查还显示,F5等负载均衡器报告了重传行为的发生率。所以值得与负载均衡器供应商核实。

Also further investigation also revealed that the load balancer such as F5 have reported incidence of retransmission behavior. So it is worth checking with your load balancer vendor as well.

这篇关于为什么用户代理在服务器进行TCP重置后重新提交请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆