Failed to load webpage - error (NSURLErrorDomain error -999) - ios

I have Phonegap project where i have requirement for open iframe, where I am trying to open an iframe with JavaScript. I get the error in iOS
Error: The operation couldn't be completed. (NSURLErrorDomain error -999)
Anyone here knows about this error or how to open iframe in Phonegap iOS.

NSURLErrorCancelled
Returned when an asynchronous load is canceled.
A Web Kit framework delegate will receive this error when it performs a cancel operation on a loading resource. Note that an NSURLConnection or NSURLDownload delegate will not receive this error if the download is canceled.
Available in OS X v10.2 and later.
Declared in NSURLError.h.

NSURLErrorDomain error -999 is triggered when asynchronous network call is cancelled.
NSURLErrorDomain error -999 == NSURLErrorCancelled
Not sure how this would help, but hopefully it'll give you a new perspective.

All the other answers are true, but what to do then?
If you catch the error with the UIWebViewDelegate, you can try reloading the content until it loaded successfully. Just insert the requestWithURL a second time in the
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
delegate. This will cycle until the page loads successfully. This is especially necessary with Facebook and Twitter. If you don't want to run into a deadlock, you can count up an int property in your object that bypasses the request after trying 5 times.

Related

AFNetwork: Getting "finished with error - code: -999" warning

I am doing a get API request and everything works fine, but I am getting the following warning in the console.
Task <13369ECB-128E-41B7-B9E4-DC7D3E47D0C1>.<2> finished with error -
code: -999
This only occurs for a certain API endpoint. This makes no sense to me at all. I thought -999 stands for cancelled request, but my requests are finished.
I think this might be a security issue simply because all my get requests work for multiple api endpoints, but not a specific one. Any suggestions are appreciated.
Yes, this means it was canceled, but the question is why
be patient to make sure you didn't cancel the request.
returned when an asynchronous load is canceled. A Web Kit framework delegate will receive this error when it performs a cancel operation on a loading resource.
may be caused by an invalid SSL certificate

HTTP load failed (error code: -999 [1:89]) for Task in iOS 11

I'm using URLSession to perform a datatask, when I run it on iOS 11, I get a console error:
HTTP load failed (error code: -999 [1:89]) for Task <68809C58-C6A7-4F10-86A4-81396D8B18CF>.<2>
Any thought on what's causing it, or how to fix it?
HTTP load failed (error code: -999 [1:89]) for Task
Error -999 means NSURLErrorCancelled, your request has been canceled before completion. According to the apple developer blog, there are few changes with ATS (likely that your server is using one of legacy crypto facilities that have been removed in iOS 11.) So give a try and implement the connection:didReceiveAuthenticationChallenge: and see if your server raises authentication challenge if yes then here is something we need to handle.
I hope it will help!
I had this error when trying to do the HTTPS
Request has been canceled before completion
In my case the SSL Certificated was not installed properly.
Check your SSL certificate if your using one.
Task <1> HTTP load failed (error code: -999 [1:89])
Task <>.<1> finished with error - code: -999
Make sure your internet connection is working. It happened to me that it's working in the simulator, but got the error on iphoneSE. I found it that my iphoneSE internet connection had a problem.

Upload task using the NSURLSessionUploadTask causing NSURLErrorDomain error -999

I am using the NSURLSessionUploadTask to upload a file to a server. Once the task is resumed, everyone now and then it fails with the error code
NSURLErrorDomain error -999
Now there is no cancel code anywhere in the app. What causes this to get canceled?
I've run into a similar issue before, the answer for me was that another same request was made before the previous request completed. I would check with breakpoints to see if your method that is uploading the file to the server might be hitting twice. Of course it could be another problem, hard to know without seeing any code but I would start there.
So the -999 in my case was a red herring. There were few misleading information on the iOS side :
The -999 error saying it was cancelled, which is user cancellation. This is not true.
The error message had the NSURLErrorBackgroundTaskCancelledReasonKey set to NSURLErrorCancelledReasonUserForceQuitApplication which was again not correct.
The actual problem was the upload file was too big for the server to accept, so the server cancelled the upload. However the translation of the server canceling the event made the error be -999 with the NSURLErrorCancelledReasonUserForceQuitApplication being the reason.

What is NSURLErrorCancelled = -999 in iOS?

Can some one describe how "NSURLErrorCancelled = -999" is used.
From Apple docs:
NSURLErrorCancelled (-999)
"Returned when an asynchronous load is canceled. A Web Kit framework
delegate will receive this error when it performs a cancel
operation on a loading resource. Note that an NSURLConnection or
NSURLDownload delegate will not receive this error if the download is
canceled."
best thing you can do about it is to ignore this error
if ([error code] != NSURLErrorCancelled) {
//here you'll get a real error
}
This error might me caused by an invalid SSL certificate. If the framework you are using to execute the request tests for valid SSL, you should add the host you are trying to connect to on a whitelist of trusted hosts.
Hope that helps anyone :)
When the URL redirects to another URL, we will receive an NSURLErrorCancelled error. And you have assigned a code value of -999 to that.

Custom HTTP headers UIWebview

I'm developing an application for iOS in Xcode 4.5 but I have a problem with a UIWebView. I want to set a header(BASE64 code) to skip a login part. When I try this, using the NPWebView project the webview always fails with an error which looks like this:
Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x6ace650 {NSErrorFailingURLKey="MY URL", NSErrorFailingURLStringKey="MY URL"}
I hope someone can help me!
I don't know from your description exactly what's going on, but -999 usually comes from the request being cancelled, in my experience.
(See https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSURLErrorCancelled)

Resources