iphone - Connection Lost error while using NSURLConnection -
I am experiencing a problem while losing the connection while using NSURLConnection. I am using NSURL connection for asynch download. I am downloading a large file size of around 80 MB, I am writing the data received every time in the file with proper file handling. After some time I am getting a connection error "Lost Connection" in the method of NSURLConnection Representative DidFailWithError If I execute the simulator on Mac then it will take a lot of time, but any suggestions that successfully downloaded the file without connection lost error How to avoid this error? Or what is the reason behind this error?
Let me know if any details are necessary. Please note that I have read this type of post but it has not been able to help me.
Below the code snippet and tell me if more information is needed:
- (zero) startdownloadfromURL: (NSString *) URLString {if (URLString == zero) {[delegate DownloadFailed: -1]; Return; } //self.pstrBaseFilePath = filePath; URL string = [URL string stringbindingprint escaping encoding: NSAPIitit encoding]; NSMutableURLRequest * pRequest = [[NSMutableURLRequest alloc] init]; [PRequest setURL: [NSURL URLWithString: URLString]]; If return (gpUserDataManager.pstrSessionID == zero); [PRequest addValue: [@ "Assaïde =" stringbafing string: GPUsourceManager.pstr session) forHTTPHeaderField: @ "cookie"]; [PRequest setHTTPMethod: @ "GET"]; [PRequest setTimeoutInterval: 180]; Self.urlConnection = [[NSURLConnection alloc] initWithRequest: pRequest Representative: Self]; [Start url connection]; } - (zero) connection: (NSURLConnection *) connection was reception: (NSURLResponse *) response {NSHTTPURLResponse * httpResponse = (NSHTTPURLResponse *) response; If ([httpResponse statusCode] == 200) {} Other {//Start.NOODLE-13304 / * NSInteger iResponseCode = [httpResponse statusCode]; NSString * pstrStr = [NSString stringWithFormat: @ "% d", iResponseCode]; // pTheConnection = Zero; [[[UIAlertView alloc] initWithTitle: NSLocalizedString (@ "response error", @ "") Message: pstrStr Representative: Cancel zeroTton title: NSLocalizedString (@ "OK", @ "") other button button: zero] show]; * / [AUserDataManager process ResponseCode: httpResponse.statusCode]; [Self. Cancel curtain]; [DownloadFell Rep: httpResponse.statusCode]; //End.NOODLE-13304} //[self.pRecvdata setLength: 0]; } - (Zero) Connection: (NSURLConnection *) Connection Was Received: (NSDT *) Data {if (auto.rcvddata == zero) {self.recvdData = [[NSMUtableData Alloc] init]; } [Self. RCVD DataApendance: Data]; } - (zero) connection: (NSURLConnection *) Connectioned filewidth error: (NSError *) error {// bIsResponseOK = FALSE; // // [NSThread detachNewThreadSelector: @selector (Spin id) toTarget: Object with self: zero]; // // pTheConnection = Zero; [[[UIAlertView alloc] initWithTitle: NSLocalizedString (@ "Connection Error", @ "") Message: [Error Localized Description] Representative: Zero CancelTutton Title: NSLocalizedString (@ "OK", @ "") Other Button Button: Zero ] Show]; [Self. Cancel curtain]; [Representative Download Downloaded: 1]; } - (zero) connectionDifffish: Loading: (NSURLConnection *) Connection {[Connection Cancellation]; [Representative Download: self.recvdData]; } DownloadRequest * request = [[DownloadRequest alloc] init]; Request.delegate = self; [Request DownloadDrudeFirm url: strURL];
Comments
Post a Comment