I am dealing with a strange network issue. On iOS 7 a server call is randomly reaching twice on sever. This does not happen with iOS 6.
From server logs it appears that same request (I am sending a unique ID in each server request) is coming twice but from client we are sending only 1 request.
Is this a known issue with iOS 7? Or am I missing something on client? Or could it be something on server?
Please suggest.
Below is my code for making a server call:
self.URLRequest = [NSMutableURLRequest requestWithURL:self.URL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:999];
[self.URLRequest setHTTPMethod:[self methodStringForMethod:self.requestMethod]];
[self.URLRequest setValue:[self.requestHeader valueForKey:aHeaderKey] forHTTPHeaderField:aHeaderKey];
[self.URLRequest setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
[self.URLRequest setHTTPBody:[self keyValuePostDataFromDictionary:self.body]];
if (self.connection) {
[self.connection cancel];
self.connection = nil;
}
self.connection = [[NSURLConnection alloc] initWithRequest:self.URLRequest delegate:self];
self.inFlight = YES;
// if we aren't on the main thread, spool the run loop to pretend to be busy until the request comes back
if ([NSThread currentThread] != [NSThread mainThread]) {
do {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
} while (self.inFlight);
}