UIWebView + iframe for livestream

I've added a frame with youtube video in WebView. It works fine:

webView.loadHTMLString("<html><head><title>.</title><style>body,html,iframe{margin:0;padding:0;}</style></head><body>
<iframe width=\"" + String(describing: w) + "\" height=\"" + String(describing: h) + "\" src=\"" + livestream.Url + "?&playinline=1\" frameborder=\"0\" allowfullscreen></iframe></body></html>", baseURL: nil)


Then I did the same for livestream.com video. I got these errors:

  • CFNetwork SSLHandshake failed (-9806)
  • SURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
  • Received memory warning.


I also added data in Info.plist file:


<dict>

     <key>NSAllowsArbitraryLoads</key>

      <true/>

      <key>NSExceptionDomains</key>

      <dict>

           <key>livestream.com</key>

           <dict>

                <key>NSIncludesSubdomains</key>

                <true/>

                <key>NSExceptionAllowsInsecureHTTPLoads</key>

                <true/>

                <key>NSExceptionMinimumTLSVersion</key>

                <string>TLSv1.1</string>

           </dict>

      </dict>

</dict>
  • CFNetwork SSLHandshake failed (-9806)

  • SURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)

In these TLS errors, what was the actual URL?

I also added data in Info.plist file:

If you want to eliminate ATS from the equation, use an

Info.plist
that only has
NSAllowsArbitraryLoads
. Using both
NSAllowsArbitraryLoads
and
NSExceptionDomains
just muddies the waters.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Actual URL is:

https://livestream.com/accounts/11528772/events/6482773/videos/139217199


I use it in iframe at WebView:

<iframe id="ls_embed_1516895384" src="http://livestream.com/accounts/11528772/events/6482773/videos/139217199/player?width=640&height=360&enableInfo=true&defaultDrawer=&autoPlay=true&mute=false" width="640" height="360" frameborder="0" scrolling="no" allowfullscreen> </iframe>


Could you add this iframe in your WebView? I think you will have the same error:


  • CFNetwork SSLHandshake failed (-9806)
  • SURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
  • Received memory warning.

Could you add this iframe in your WebView?

I gave that a try. Here’s the code I used:

let html = """
<iframe id="ls_embed_1516895384" src="http://livestream.com/accounts/11528772/events/6482773/videos/139217199/player?width=640&height=360&enableInfo=true&defaultDrawer=&autoPlay=true&mute=false" width="640" height="360" frameborder="0" scrolling="no" allowfullscreen> </iframe>
"""

@IBAction func testAction(_ sender: AnyObject) {
    self.webView.loadHTMLString(self.html, baseURL: nil)
}

where

self.webView
is a
WKWebView
set up with the default configuration. It worked just fine for me (tested on a device running iOS 11.2.2). And by “worked”, I mean:
  • I saw a video UI.

  • Tapping on its play button lead to playing video.

btw The error you’re seeing, -9806, is defined as

errSSLClosedAbort
. This has a lot of potential causes, but they’re all caused by the TLS stack getting something unexpected in from the ‘wire’.

ps I just noticed you mentioned

UIWebView
in the subject line, so I retried my test with
UIWebView
and also didn’t see the problem. Realistically though, you should be using
WKWebView
unless you have some compelling reason to stick with a web view that’s effectively, although not officially, deprecated.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
UIWebView &#43; iframe for livestream
 
 
Q