Undocumented NSURLErrorDomain error codes (-1001, -1003, and -1004) using StoreKit

I am writing code related to StoreKit and I get some rather disturbing error codes when I try to add a purchase to the queue.

So far I have encountered error codes -1003 and -1004, and I can not find anything about these codes on the Internet.

Running a product request returns valid product numbers, so I donโ€™t know why calls [[SKPaymentQueue defaultQueue] addPayment:aPayment]; ended up with this undocumented problem.

The same code also works without errors on one device, but not on another.

The questions that I have are still unanswered:

What do these codes mean? How can I mitigate this problem? Why do they occur for purchases and not for product requests?

The troubleshooting that I performed included the restoration of the signature certificate and service profile, changing Wi-Fi networks, cleaning and assembling and reinstalling all related programs and components, and none of these individually or together helped to fix the problem.

EDIT:

Found a discussion about this on the Apple dev forums, but none of Apple answered: https://devforums.apple.com/thread/107121?tstart=75 (iOS developer account is required for view)

EDIT:

Today, I was struck by error code -1001 to add unexplained and intermittent issues to this list. However, I cannot report to Apple.

EDIT:

I have a suspicion that these error codes are randomly generated and actually only indicate that the sandbox is turned off. Anyone else having this problem?

+84
ios storekit nsurlerrordomain
Jul 21 '11 at 2:59 a.m.
source share
6 answers

All error codes are included in the โ€œCFNetwork Error Code Linksโ€ documentation ( link )

A small extract for CFURL and CFURLConnection errors:

  kCFURLErrorUnknown = -998, kCFURLErrorCancelled = -999, kCFURLErrorBadURL = -1000, kCFURLErrorTimedOut = -1001, kCFURLErrorUnsupportedURL = -1002, kCFURLErrorCannotFindHost = -1003, kCFURLErrorCannotConnectToHost = -1004, kCFURLErrorNetworkConnectionLost = -1005, kCFURLErrorDNSLookupFailed = -1006, kCFURLErrorHTTPTooManyRedirects = -1007, kCFURLErrorResourceUnavailable = -1008, kCFURLErrorNotConnectedToInternet = -1009, kCFURLErrorRedirectToNonExistentLocation = -1010, kCFURLErrorBadServerResponse = -1011, kCFURLErrorUserCancelledAuthentication = -1012, kCFURLErrorUserAuthenticationRequired = -1013, kCFURLErrorZeroByteResource = -1014, kCFURLErrorCannotDecodeRawData = -1015, kCFURLErrorCannotDecodeContentData = -1016, kCFURLErrorCannotParseResponse = -1017, kCFURLErrorInternationalRoamingOff = -1018, kCFURLErrorCallIsActive = -1019, kCFURLErrorDataNotAllowed = -1020, kCFURLErrorRequestBodyStreamExhausted = -1021, kCFURLErrorFileDoesNotExist = -1100, kCFURLErrorFileIsDirectory = -1101, kCFURLErrorNoPermissionsToReadFile = -1102, kCFURLErrorDataLengthExceedsMaximum = -1103, 
+281
Feb 23 '12 at 14:59
source share

I have similar problems, in my case it seems to be related to network connections:

Domain Error = NSURLErrorDomain Code = -1001 "Request Timeout".

What you need to check:

  • Is it likely that your server will not be able to respond within a certain period of time? How 60 seconds or 4 minutes?
  • Is it possible that your device is switching networks (WiFi, 3G, VPN)?
  • Can someone (client or server) wait for authentication?

Sorry, no idea how to fix it. Just debug this while trying to figure out what the problem is (-1021, -1001, -1009)

Update: Google search was very kind to find this:

  • -1001 TimedOut - It took more time to be allocated.
  • -1003 CannotFindHost - host not found.
  • -1004 CannotConnectToHost - the host will not allow us to establish a connection.
+25
Sep 20 2018-11-21T00:
source share

see NSURLError.h Define

 NSURLErrorUnknown = -1, NSURLErrorCancelled = -999, NSURLErrorBadURL = -1000, NSURLErrorTimedOut = -1001, NSURLErrorUnsupportedURL = -1002, NSURLErrorCannotFindHost = -1003, NSURLErrorCannotConnectToHost = -1004, NSURLErrorNetworkConnectionLost = -1005, NSURLErrorDNSLookupFailed = -1006, NSURLErrorHTTPTooManyRedirects = -1007, NSURLErrorResourceUnavailable = -1008, NSURLErrorNotConnectedToInternet = -1009, NSURLErrorRedirectToNonExistentLocation = -1010, NSURLErrorBadServerResponse = -1011, NSURLErrorUserCancelledAuthentication = -1012, NSURLErrorUserAuthenticationRequired = -1013, NSURLErrorZeroByteResource = -1014, NSURLErrorCannotDecodeRawData = -1015, NSURLErrorCannotDecodeContentData = -1016, NSURLErrorCannotParseResponse = -1017, NSURLErrorAppTransportSecurityRequiresSecureConnection NS_ENUM_AVAILABLE(10_11, 9_0) = -1022, NSURLErrorFileDoesNotExist = -1100, NSURLErrorFileIsDirectory = -1101, NSURLErrorNoPermissionsToReadFile = -1102, NSURLErrorDataLengthExceedsMaximum NS_ENUM_AVAILABLE(10_5, 2_0) = -1103, // SSL errors NSURLErrorSecureConnectionFailed = -1200, NSURLErrorServerCertificateHasBadDate = -1201, NSURLErrorServerCertificateUntrusted = -1202, NSURLErrorServerCertificateHasUnknownRoot = -1203, NSURLErrorServerCertificateNotYetValid = -1204, NSURLErrorClientCertificateRejected = -1205, NSURLErrorClientCertificateRequired = -1206, NSURLErrorCannotLoadFromNetwork = -2000, // Download and file I/O errors NSURLErrorCannotCreateFile = -3000, NSURLErrorCannotOpenFile = -3001, NSURLErrorCannotCloseFile = -3002, NSURLErrorCannotWriteToFile = -3003, NSURLErrorCannotRemoveFile = -3004, NSURLErrorCannotMoveFile = -3005, NSURLErrorDownloadDecodingFailedMidStream = -3006, NSURLErrorDownloadDecodingFailedToComplete =-3007, NSURLErrorInternationalRoamingOff NS_ENUM_AVAILABLE(10_7, 3_0) = -1018, NSURLErrorCallIsActive NS_ENUM_AVAILABLE(10_7, 3_0) = -1019, NSURLErrorDataNotAllowed NS_ENUM_AVAILABLE(10_7, 3_0) = -1020, NSURLErrorRequestBodyStreamExhausted NS_ENUM_AVAILABLE(10_7, 3_0) = -1021, NSURLErrorBackgroundSessionRequiresSharedContainer NS_ENUM_AVAILABLE(10_10, 8_0) = -995, NSURLErrorBackgroundSessionInUseByAnotherProcess NS_ENUM_AVAILABLE(10_10, 8_0) = -996, NSURLErrorBackgroundSessionWasDisconnected NS_ENUM_AVAILABLE(10_10, 8_0)= -997, 
+11
Sep 14 '16 at 3:08
source share

I use the following method in my project

 -(NSArray*)networkErrorCodes { static NSArray *codesArray; if (![codesArray count]){ @synchronized(self){ const int codes[] = { //kCFURLErrorUnknown, //-998 //kCFURLErrorCancelled, //-999 //kCFURLErrorBadURL, //-1000 //kCFURLErrorTimedOut, //-1001 //kCFURLErrorUnsupportedURL, //-1002 //kCFURLErrorCannotFindHost, //-1003 kCFURLErrorCannotConnectToHost, //-1004 kCFURLErrorNetworkConnectionLost, //-1005 kCFURLErrorDNSLookupFailed, //-1006 //kCFURLErrorHTTPTooManyRedirects, //-1007 kCFURLErrorResourceUnavailable, //-1008 kCFURLErrorNotConnectedToInternet, //-1009 //kCFURLErrorRedirectToNonExistentLocation, //-1010 kCFURLErrorBadServerResponse, //-1011 //kCFURLErrorUserCancelledAuthentication, //-1012 //kCFURLErrorUserAuthenticationRequired, //-1013 //kCFURLErrorZeroByteResource, //-1014 //kCFURLErrorCannotDecodeRawData, //-1015 //kCFURLErrorCannotDecodeContentData, //-1016 //kCFURLErrorCannotParseResponse, //-1017 kCFURLErrorInternationalRoamingOff, //-1018 kCFURLErrorCallIsActive, //-1019 //kCFURLErrorDataNotAllowed, //-1020 //kCFURLErrorRequestBodyStreamExhausted, //-1021 kCFURLErrorFileDoesNotExist, //-1100 //kCFURLErrorFileIsDirectory, //-1101 kCFURLErrorNoPermissionsToReadFile, //-1102 //kCFURLErrorDataLengthExceedsMaximum, //-1103 }; int size = sizeof(codes)/sizeof(int); NSMutableArray *array = [[NSMutableArray alloc] init]; for (int i=0;i<size;++i){ [array addObject:[NSNumber numberWithInt:codes[i]]]; } codesArray = [array copy]; } } return codesArray; } 

Then I just check the error code and show a warning if it is in the list

 if ([[self networkErrorCodes] containsObject:[NSNumber numberWithInt:[error code]]]){ // Fire Alert View Here } 

But, as you can see, I commented on codes that, it seems to me, do not match my definition of NO INTERNET. For example, code -1012 (Authentication Error). You can edit the list as you wish.

In my project, I use it when entering a username and password from a user. And in my opinion, a (physical) network connection may be the only reason to show a warning in a network-based application. In any other case (for example, an incorrect pair of user / password words), I prefer to do some kind of user-friendly animation, OR just retry the failed attempt again without any user attention. Especially if the user has not explicitly initiated a network call.

Regarding martinezdelariva for reference to documentation.

+4
Apr 26 '14 at 9:40
source share
+1
Oct. 15 '14 at 13:12
source share

I found a new error code that is not described above: CFNetworkErrorCode -1022

 Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." 
0
Nov 29 '16 at 10:42 on
source share



All Articles