I have an issue with casting some third party audio streams. I have relied heavily on https://developers.google.com/cast/docs/player and followed those instructions on how to create a custom receiver for playing the streams.

After just a second or so after starting the stream (I don't get any sound) the Cast devices freezes and they stop responding to debug via Chrome and they don't react to stopping the Cast session. Often they are so locked that even issuing a reboot via the Home app doesn't work; I have to physically disconnect the power.

It's the same behaviour on Chromecast v2 (1.22.79313), Chromecast Ultra (1.22.78017) and Google Home (1.22.78295).

**What could the cause of this freeze be? Is this caused by some very broken streams? Is it a known issue? Are there any workarounds? Shouldn't one expect the Cast devices to handle this and give some error message and not crash like this?**

This is the log I get from the Chrome Developer Tools before the connection is reset:

    cast_receiver.js:67  [  0.268s] [cast.receiver.IpcChannel] Opening platform websocket
    cast_receiver.js:67  [  0.292s] [cast.receiver.CastReceiverManager] Version: 2.0.0.0049
    cast_receiver.js:67  [  0.305s] [cast.receiver.MediaManager] Using default Player
    cast_receiver.js:67  [  0.314s] [cast.receiver.IpcChannel] Opening message bus websocket
    cast_receiver.js:67  [  0.322s] [cast.receiver.IpcChannel] IpcChannel opened
    cast_receiver.js:67  [  0.326s] [cast.receiver.CastMessageBus] Dispatching CastMessageBus message
    cast_receiver.js:67  [  0.333s] [cast.receiver.CastReceiverManager] Underlying message bus is open
    [...]
    media_player.js:25  [  0.628s] [cast.player.api.Player] Version: 1.0.0.40
    [...]
    media_player.js:25  [  6.682s] [cast.player.api.Player] load
    media_player.js:25  [  6.707s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/playlist.m3u8 -1]
    media_player.js:25  [  6.721s] [goog.net.XhrIo] Will abort after 30000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/playlist.m3u8 -1]
    media_player.js:25  [  6.725s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/playlist.m3u8 -1]
    media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/playlist.m3u8'. This content should also be served over HTTPS.
    media_player.js:25  [  6.735s] [cast.player.core.MediaSourceManager] open
    media_player.js:25  [  6.923s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/playlist.m3u8 200]
    media_player.js:25  [  6.975s] [cast.player.core.QualityManager] 0: initial 82625
    media_player.js:25  [  6.986s] [cast.player.hls.Playlist] update: http://thirdpartyserver.example.com/chunklist_w941582493.m3u8
    media_player.js:25  [  6.993s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 -1]
    media_player.js:25  [  6.999s] [goog.net.XhrIo] Will abort after 30000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 -1]
    media_player.js:25  [  7.004s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 -1]
    media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/chunklist_w941582493.m3u8'. This content should also be served over HTTPS.
    media_player.js:25  [  7.127s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 200]
    media_player.js:25  [  7.140s] [cast.player.hls.Playlist] update in: 3000
    media_player.js:25  [  7.161s] [cast.player.core.SegmentManager] 0: seek success 0
    media_player.js:25  [  7.169s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac -1]
    media_player.js:25  [  7.174s] [goog.net.XhrIo] Will abort after 10000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac -1]
    media_player.js:25  [  7.180s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac -1]
    media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/media_w941582493_4220443.aac'. This content should also be served over HTTPS.
    media_player.js:25  [  7.311s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac 200]
    media_player.js:25  [  7.322s] [cast.player.core.QualityManager] 0: current=1018961.04, average=1444314.43
    media_player.js:25  [  7.330s] [cast.player.core.SegmentManager] 0: process segment
    media_player.js:25  [  7.338s] [cast.player.hls.Adaptation] process segment
    media_player.js:25  [  7.357s] [cast.player.core.SegmentManager] 0: segment processed
    media_player.js:25  [  7.363s] [cast.player.core.SourceBufferManager] 0: queue append
    media_player.js:25  [  7.382s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac -1]
    media_player.js:25  [  7.387s] [goog.net.XhrIo] Will abort after 10000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac -1]
    media_player.js:25  [  7.392s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac -1]
    media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/media_w941582493_4220444.aac'. This content should also be served over HTTPS.
    media_player.js:25  [  7.515s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac 200]
    media_player.js:25  [  7.521s] [cast.player.core.QualityManager] 0: current=1113553.96, average=1179706.05
    media_player.js:25  [  7.528s] [cast.player.core.SegmentManager] 0: process segment
    media_player.js:25  [  7.533s] [cast.player.hls.Adaptation] process segment


##Update - more info:

The response headers for that first request (`playlist.m3u8`) are as follows:

    Accept-Ranges:bytes
    Access-Control-Allow-Credentials:true
    Access-Control-Allow-Headers:Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
    Access-Control-Allow-Methods:OPTIONS, GET, POST, HEAD
    Access-Control-Allow-Origin:*
    Access-Control-Expose-Headers:Date, Server, Content-Type, Content-Length
    Cache-Control:no-cache
    Content-Length:105
    Content-Type:application/vnd.apple.mpegurl
    Date:Tue, 21 Mar 2017 13:44:37 GMT
    Server:WowzaStreamingEngine/4.5.0

The response body for that first request (`playlist.m3u8`) is as follows:

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:BANDWIDTH=80053,CODECS="mp4a.40.2"
    chunklist_w941582493.m3u8

The response headers for that second request (`chunklist_w941582493.m3u8`) are as follows:

    Accept-Ranges:bytes
    Access-Control-Allow-Credentials:true
    Access-Control-Allow-Headers:Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
    Access-Control-Allow-Methods:OPTIONS, GET, POST, HEAD
    Access-Control-Allow-Origin:*
    Access-Control-Expose-Headers:Date, Server, Content-Type, Content-Length
    Cache-Control:no-cache
    Content-Length:213
    Content-Type:application/vnd.apple.mpegurl
    Date:Tue, 21 Mar 2017 13:44:37 GMT
    Server:WowzaStreamingEngine/4.5.0

The response body for that second request (`chunklist_w941582493.m3u8`) is typical something as follows:

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:3
    #EXT-X-MEDIA-SEQUENCE:4272014
    #EXTINF:1.95,
    media_w1552860397_4272014.aac
    #EXTINF:2.09,
    media_w1552860397_4272015.aac
    #EXTINF:1.95,
    media_w1552860397_4272016.aac

The response headers for that second request (`media_w941582493_4220443.aac`) are as follows:

    Accept-Ranges:bytes
    Access-Control-Allow-Credentials:true
    Access-Control-Allow-Headers:Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
    Access-Control-Allow-Methods:OPTIONS, GET, POST, HEAD
    Access-Control-Allow-Origin:*
    Access-Control-Expose-Headers:Date, Server, Content-Type, Content-Length
    Cache-Control:no-cache
    Content-Length:19757
    Content-Type:audio/x-aac
    Date:Tue, 21 Mar 2017 13:44:37 GMT
    Server:WowzaStreamingEngine/4.5.0