Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what cause error NSNetServicesErrorCode = "-72000"?

i create a simple browser that can load a local file using UIWebview. At first,when i try to preview a html file, the uiwebview can load the source file and preview it. But after i minimize the app (the app enter background), and then open the app again, i've got this error :

Error Dict: {
    NSNetServicesErrorCode = "-72000";
    NSNetServicesErrorDomain = 10;
}

and after that, the uiwebview can not load the source file, when i log the error in (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error, it shows this message :

Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo=0x53d610 {NSErrorFailingURLStringKey=http://localhost:9898/local/a.html?83C66B33-874C-41A7-BBF5-78D1615512DF, NSErrorFailingURLKey=http://localhost:9898/local/a.html?83C66B33-874C-41A7-BBF5-78D1615512DF, NSLocalizedDescription=Could not connect to the server., NSUnderlyingError=0x5ccaa0 "Could not connect to the server."}

the app isn't crash, but the spinning indicator is never stop.

could somebody tell me what cause this case? and how to solved it?

Thank you :)

like image 382
R. Dewi Avatar asked May 11 '12 11:05

R. Dewi


1 Answers

If you look inside the NSNetServices header, you'll see the following enum that explains each error:

typedef NS_ENUM(NSInteger, NSNetServicesError) {

/* An unknown error occured during resolution or publication.
*/
    NSNetServicesUnknownError = -72000L,

/* An NSNetService with the same domain, type and name was already present when the publication request was made.
*/
    NSNetServicesCollisionError = -72001L,

/* The NSNetService was not found when a resolution request was made.
*/
    NSNetServicesNotFoundError  = -72002L,

/* A publication or resolution request was sent to an NSNetService instance which was already published or a search request was made of an NSNetServiceBrowser instance which was already searching.
*/
    NSNetServicesActivityInProgress = -72003L,

/* An required argument was not provided when initializing the NSNetService instance.
*/
    NSNetServicesBadArgumentError = -72004L,

/* The operation being performed by the NSNetService or NSNetServiceBrowser instance was cancelled.
*/
    NSNetServicesCancelledError = -72005L,

/* An invalid argument was provided when initializing the NSNetService instance or starting a search with an NSNetServiceBrowser instance.
*/
    NSNetServicesInvalidError = -72006L,

/* Resolution of an NSNetService instance failed because the timeout was reached.
*/
    NSNetServicesTimeoutError = -72007L,

};

You're getting a service collision error, which means that a net service with the same domain, type, and name are already publishing their service on your network.

In general, I always consult the header file for error codes. They're nearly always assigned by an enum value, and the enum usually has a much more descriptive name than the number used.

like image 108
Sean Michael Dorian Avatar answered Sep 24 '22 18:09

Sean Michael Dorian