Approximately 10% of the POST or PUT requests I make to my Node.js HTTPS server take 2 minutes to get a response. The other 90% behave as expected.
I have verified with tshark that the body of the request is received by the server, but then it takes 2 minutes to trigger the 'data' and 'end' events of the ServerRequest object.
The requests that experience this latency appear to be random, but when it does happen, the time of the latency between receiving the packet and the 'data' and 'end' events being triggered is always exactly 2 minutes.
For all of these requests I'm posting a small json object that's arriving in a single packet. For the requests experiencing latency, I know the headers are received by my application because the session cookie is parsed immediately. After session authentication, nothing happens until the 'data' and 'end' events are finally emitted 2 minutes later, at which time the body is parsed and saved to my database.
Is this more likely to be an issue with my Node application or a problem with my server, which is an EC2 small instance running Amazon Linux? How is it that it's taking 2 minutes from the time the packet with body of the request arrives until it's passed as a chunk to my application?
Thanks.
Update: I modified parser.onBody in lib/http.js to log 'b' and I can see that this method is not being invoked until the end of the two minute delay. This seems to indicate that the problem is at a lower level than my application. I also changed ec2 instances, but that didn't help.