Hi there
So, I am using NSURLRequest in my app twice to get two .txt files from my server using the following code:
and am having some problems with the timings. I use the following in terminal to setup a pipe to my server, increasing the ping to simulate a poor internet connection (to test the app in such an environment).
I have this setup for a pipe to and from my server, so when I ping the server in terminal I get a ping time of a little over 3000ms. Because my timeout is 5s, I would not have thought this was a problem. However, I am having a problem with the first request, as follows:
In my log, I get:
which shows that it takes 6.3 seconds from checking maintenance mode to getting the first file, and then the second files comes just over 3000ms after it is first requested.
My question is: why does the first file not come just over 3000ms after it is first requested also? Seems very odd?
Thanks,
Sam
So, I am using NSURLRequest in my app twice to get two .txt files from my server using the following code:
Code:
NSString *responseStringIfYes;
NSURLResponse *responseIfYes;
NSError *errorIfYes = nil;
NSURLRequest *requestIfYes = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:@"http://my-site.com/open-if-no--maintenance-mode-if-yes.txt"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:5]; // 5 second timeout?
NSData* dataIfYes = [NSURLConnection sendSynchronousRequest:requestIfYes returningResponse:&responseIfYes error:&errorIfYes];
responseStringIfYes = [[NSString alloc] initWithData:dataIfYes encoding:NSUTF8StringEncoding];
NSLog(@"Recieved String Result: %@", responseStringIfYes);
// Get text for the message contents.
NSString *responseStringMessage;
NSURLResponse *responseMessage;
NSError *errorMessage = nil;
NSURLRequest *requestMessage = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:@"http://my-site.com/maintenance-message-contents.txt"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:5]; // 5 second timeout?
NSData* dataMessage = [NSURLConnection sendSynchronousRequest:requestMessage returningResponse:&responseMessage error:&errorMessage];
responseStringMessage = [[NSString alloc] initWithData:dataMessage encoding:NSUTF8StringEncoding];
NSLog(@"Recieved String Result: %@", responseStringMessage);
and am having some problems with the timings. I use the following in terminal to setup a pipe to my server, increasing the ping to simulate a poor internet connection (to test the app in such an environment).
Code:
ipfw pipe 1 config delay 1500ms bw 1Mbit/s plr 0
I have this setup for a pipe to and from my server, so when I ping the server in terminal I get a ping time of a little over 3000ms. Because my timeout is 5s, I would not have thought this was a problem. However, I am having a problem with the first request, as follows:
In my log, I get:
Code:
2013-03-22 17:27:40.385 Million Taps[5898:c07] Checking Maintenance Mode
2013-03-22 17:27:46.623 Million Taps[5898:c07] Recieved String Result: no
2013-03-22 17:27:49.746 Million Taps[5898:c07] Recieved String Result: Maintenance Mode Active
which shows that it takes 6.3 seconds from checking maintenance mode to getting the first file, and then the second files comes just over 3000ms after it is first requested.
My question is: why does the first file not come just over 3000ms after it is first requested also? Seems very odd?
Thanks,
Sam