相关文章推荐
大气的电池  ·  NameError: name ...·  1 周前    · 
唠叨的鸵鸟  ·  PROC相关-CSDN博客·  3 周前    · 
豪气的哑铃  ·  OpenGL ES 3.0 ...·  7 月前    · 
唠叨的硬盘  ·  jupyter notebook - ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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 stopped:

NSURLConnection finished with error - code -1002

I paste this code (this code i saw on stackowerflow) but it's not help to me:

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

Maybe you know best solution?

it's obligation? i have 8 http stream's and on iOS 10 work perfectly but on iOS 11 - after 5 minutes player stop – Genevios Oct 12, 2017 at 10:55 I answered your concern in "Answer" section because in comment area it is difficult to address your issue. – Zeeshan Arif Oct 12, 2017 at 11:08 Thanks man, but i have audio stream and how i know audio stream it's not necessary to use https.. – Genevios Oct 12, 2017 at 11:13

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.

It's possible to send me screen how look like this line, because i am not understand. Thanks. It will be very advisable for all who follow my question. – Genevios Dec 6, 2017 at 11:55 But anyway new Xcode very annoying with new issues TIC and it's not only my opinion, just look AppStore rating of new Xcode version... – Genevios Dec 9, 2017 at 17:06 Nothing to do with Xcode. It's additional debugging in that version of iOS (and, by extension, the simulator). – dgatwood Dec 10, 2017 at 0:17

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"];
                Any illegal character should cause the NSURL to be nil, so if you can create an NSURL from it successfully, it shouldn't be an illegal character issue, and if you can't, well then there's your problem.  :)
– dgatwood
                May 29, 2020 at 19:13

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;
                I will try this after 2-3 days and answer, if it's ok i will accept your answer, but anyway thanks!
– Genevios
                Oct 12, 2017 at 11:23
                This is a very, very bad idea.  This disables all URL request security for your entire app, and your app will be rejected from the iOS App Store if you try it.
– dgatwood
                Nov 28, 2017 at 17:56
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.