9
votes

I am using HTTP Post method and initiating a synchronous request. [NSURLConnection sendSynchronousRequest: ..]

For HTTP POST requests, the default time out is happening at 75 seconds as discussed in many threads.

But during that time out period of 75 seconds, Multiple web service requests are getting initiated for us for the same request raised with all the same parameters.

Please let us know What causes this multiple requests to get initiated? Is this due to HTTP POST in general or because of Synchronous request?

@iOS Sample Code

[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
[request addValue:[NSString stringWithFormat:@"%d", body.length] forHTTPHeaderField: @"Content-Length"];

 [[NSURLCache sharedURLCache] setDiskCapacity:0];
 [[NSURLCache sharedURLCache] setMemoryCapacity:0];

 NSURLResponse *response;
 response = nil;

 urlData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];              
 if(urlData)
 {
        NSString *responseString = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding];
        [self parseStringInformation:responseString infoDict:informationDictionary];
        //NSLog(@"%@",responseString);
 }
1
Could you drop a sample part of your source, may be there is something wrong. I have never got such a behaviour.iOS
@iOS Added sample code aboveSubi
Interesting, I would like to check and log all the events which will be visible during asynchronous transfer, may be the system has some reasons for redirects which lead to the multiple requests. Just for debugging I would recommend to use the asynchron post and put in all the events and log them with NSLog() to see what happens from the system side. Afaik there are no ways to log these events in synchronous mode. Hope that this helps, otherwise I just could check the transfer from my system.iOS
I am facing a similar issue. My app has been working for past 2 years without any issue. Recently I noticed this multiple POSTs and when I analysed, this issue started from Mid-Sep. I notice that IOS6 was available to users somewhere that time and users started upgrading to IOS 6. I am going to explore in that direction (no conclusion yet). Anyone else in the forum observed this? Any pointers where we can explore further?zolio

1 Answers

1
votes

Without the server's request-response logs there are several possibilities.

Programmer Error: Have you already gone through all of "gotchya" type situations?

Web Server Responses: Without the web servers logs (or the code for the service your POSTing to) it's hard to say...

API Error: You've found some corner case which is causing unwanted side effects. Maybe apple has an bug tracker or developer support forum?