NSURLConnection finished with error - code -1002

后端 未结 3 1916
无人及你
无人及你 2021-02-07 01:27

Friends i have simple audio player (MPMoviePlayerController) which can play audio stream. On iOS 11 i have very interessing trouble, thousand time i have error and my stream was

相关标签:
3条回答
  • 2021-02-07 01:45

    This issue can appear if your URL contains spaces. I solved it by replacing the spaces with "%20", and then you can use it safely. The Objective C code to replace the spaces is below.

    your_url_variable_name = [your_url_variable_name stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    
    0 讨论(0)
  • 2021-02-07 01:51

    That error should not be related to using HTTP instead of HTTPS. App Transport Security failures return error code -1022.

    The error code -1002 indicates an invalid URL. Perhaps your HTTP live streaming playlist file contains a structurally invalid URL (e.g. missing scheme, a scheme other than http/https, etc.)?

    For additional debugging, set this environment variable

    CFNETWORK_DIAGNOSTICS=1
    

    in your Xcode project and re-run the app. Once you know what URL is failing, the problem will likely become more obvious.

    If it isn't, file a bug.

    0 讨论(0)
  • 2021-02-07 02:03

    First thing you must use secure server (server with valid certificate). I'm not sure either it is necessary or not because i never tried to hit server with invalid certificate. You can try this code (not sure it will work for you or not) put this code in Appdelegate.m

    @implementation NSURLRequest(DataController)
    + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
    {
        return YES;
    }
    @end
    
    0 讨论(0)
提交回复
热议问题