What is NSURLErrorCancelled = -999 in iOS? - 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.

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.

iOS - Runtime errors with GCM

I'm not sure if this is an issue of the library or something wrong on our side but I already spent a lot of time searching about this and found nothing that could shed any light.
We're using GCM since a while on both iOS and Android. The application is in production and is working fine. Our iOS app collects and reports low-impact errors (basically errors we catch and handle) and analyzing these data I found those errors I'm struggling to understand.
While registering a device on GCM with an APNS token
Error Domain=com.google.iid Code=1006 "(null)" that according to the documentation is kGGLInstanceIDOperationErrorCodeInvalidKeyPair
While subscribing to a topic
Error Domain=com.google.gcm Code=501 "(null)" that according to the documentation is kGGLInstanceIDOperationErrorCodeMissingDeviceID
Both errors happens on iOS8/iOS9/iOS10.
Our app includes the GCM library via Cocoapods:
pod 'Google/CloudMessaging', '2.0.4'
Can someone help me understanding what's happening?
Thanks!
The first error kGGLInstanceIDOperationErrorCodeInvalidKeyPair means that you have error in KeyPair access. While the error kGGLInstanceIDOperationErrorCodeMissingDeviceID means that your device seems to be missing a valid deviceID. It cannot authenticate device requests. From this related thread, error code 501 was solved by resetting all data and settings on the device (factory reset) and this fixed the problem. It's also stated here that the error occurred maybe because you are calling GCMService.sharedInstance().connectWithHandler() { error in if(error != nil) { print(error) } } before you had received a registration token, or had failed to refresh your token.
But I found this SO question which have similar issue with you which suggests to transition to Firebase Cloud Messaging as recommended by Google and his issue was solved.

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.

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

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.

Resources