NSURLConnection completed with error code -1002

I have a simple audio player (MPMoviePlayerController) that can play an audio stream. On iOS 11, I am very worried about problems, I have had a thousand times error, and my thread has been stopped:

NSURLConnection finished with error - code -1002 

I embed this code (I saw this code on stackowerflow), but this does not help me:

 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>cast.mysite.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> </dict> </dict> </dict> 

Maybe you know the best solution?

+7
xcode nsurlconnection mpmovieplayercontroller ios11
source share
2 answers

This error should not be related to using HTTP instead of HTTPS. Transport application security errors return error code -1022.

Error code -1002 indicates an invalid URL. Perhaps your streaming file in the HTTP streaming stream contains a structurally invalid URL (for example, a missing scheme, a scheme other than http / https, etc.)?

For additional debugging, set this environment variable

 CFNETWORK_DIAGNOSTICS=1 

in your Xcode project and restart the application. Once you find out which URL is failing, the problem is likely to become more obvious.

If this is not the case, write a mistake.

+13
source share

First of all, you must use a secure server (a server with a valid certificate). I am not sure if this is necessary or not, because I have never tried to attack a server with an invalid certificate. You can try this code (not sure if it will work for you or not) put this code in Appdelegate.m

 @implementation NSURLRequest(DataController) + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host { return YES; } @end 
0
source share

All Articles