We use NSUrlConnection sendAsynchronousRequest to send simple POST requests to our Node JS server. After analyzing tcpdumps, we noticed that sometimes the request headers and the request body are divided into 2 separate TCP packets.
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:url]]; [request setTimeoutInterval:3]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-type"]; [request setHTTPBody:postData]; [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler: ^(NSURLResponse *response, NSData *POSTReply, NSError *error) { }];
The problem is that sometimes headers are sent to the server, which opens a connection to our API, and then after a few seconds the body packet is sent. We see a 1 second delay between the headers and the body, randomly every hundreds of server-side requests. This is the biggest source of latency in our API.
For most requests, the headers and body are the same size (200 bytes each).
Has anyone seen this before?
user2872082
source share