Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the user agent resubmit a request after server does a TCP reset?

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

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.

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.

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

like image 782
billc.cn Avatar asked Nov 06 '13 15:11

billc.cn


1 Answers

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.

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

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.

like image 124
thiru Avatar answered Sep 20 '22 13:09

thiru