Not getting all the data over the cell network
Not getting all the data over the cell network
- Subject: Not getting all the data over the cell network
- From: Stevo Brock <email@hidden>
- Date: Fri, 10 Aug 2012 11:32:59 -0700
We are seeing quite an odd situation in our iOS app. When running the app on an iPhone 4 with iOS 4.3.5 (other combinations also exhibit this behavior but I don't have the exact details at the moment) and forcing data traffic to go over the AT&T cell network, our URL data loading calls are often not returning the entire set of bytes. Here is the code:
Option 1: Basic NSData* data = "" dataWithContentsOfURL:mURL];
Option 2: Check for return error NSError* error = nil; NSData* data = "" alloc] initWithContentsOfURL:mURL 0 error:&error] autorelease];
Option 3: Use NSURLConnection NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:mURL]; NSHTTPURLResponse* response = nil; NSError* error = nil; NSData* data = "" sendSynchronousRequest:request returningResponse:&response error:&error]; NSInteger responseStatus = [response statusCode]; NSLog(@"response code: %d", responseStatus); NSLog(@"response headers: %@", [response allHeaderFields]);
Returns the following info every time:
2012-08-08 11:54:20.815 App[994:8207] response code: 200 2012-08-08 11:54:20.817 App[994:8207] response headers: { "Accept-Ranges" = bytes; "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; "Content-Encoding" = gzip; "Content-Length" = 87187; "Content-Type" = "application/pdf"; Date = "Wed, 08 Aug 2012 18:54:20 GMT"; Expires = "Thu, 19 Nov 1981 08:52:00 GMT"; P3p = "CP=\"NOI DSP COR CUR IVD OTPi OUR STP INT\", policyref=\"/w3c/p3p.xml\""; Pragma = "no-cache"; Server = "Apache/2.2.3 (CentOS)"; "Set-Cookie" = "fromov=deleted; expires=Tue, 09-Aug-2011 18:54:19 GMT; path=/"; Vary = "Accept-Encoding"; }
Option 4: Try on main thread NSMutableData* storageData = [NSMutableData data]; [self performSelectorOnMainThread:@selector(loadURL:) withObject: storageData waitUntilDone:YES];
- (void) loadURL:(NSMutableData*) storageData { NSData* data = "" dataWithContentsOfURL:mURL]; [storageData appendData:data]; }
What we see is that occasionally (25% of the time?) the app loads all 87187 bytes, but the rest of the time, the app loads less data (around 5K to 10K) and no error or any other condition is ever returned. As far as I can tell the data that does arrive is correct, just truncated.
Does anyone have any idea what could be going wrong and perhaps what is the recommended approach to consistently and correctly loading data over the cell network?
-Stevo Brock Sunset Magicwerks, LLC 818-609-0258
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden