This project has moved and is read-only. For the latest updates, please go here.

System.IO.IOException/System.Net.Http.HttpRequestException occurred.

Feb 27, 2014 at 3:41 PM
First of all, thanks for this project.

My test environment is as follows,

Source download: phonesm-6fadcf3951d3e5363f7bb162bd9f143c6647907b.zip
Tool: VS2013 Pro
Test Application: HlsView.Win81

I just used original source code, only changed this media url.
            InitializeMediaStream();

            _mediaStreamFascade.Source = new Uri(
                "http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/playlist.m3u8"
                );

            mediaElement1.Play();
To reproduce the problem, you can test it now with "http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/playlist.m3u8".

With this media in action, System.IO.IOException occurred within 1-minute.

The log messages in debug mode are like this,

MediaStreamFascade.SetMediaSourceAsync(http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/playlist.m3u8)
MediaStreamFascade.OpenMediaAsync()
...[ommitted for brevity]...
WinRtMediaElementManager.SetSourceAsync() handler
Media MediaStreamSourceAssigned: Idle -> Assigned at 02/28/2014 00:24:11 +09:00
MediaElement State: Opening
WintRtMediaStreamSource.RegisterMediaStreamSourceHandler()
TsMediaManager.OpenMedia()
TsMediaManager.OpenMedia() handler
MediaStreamFascade.MediaManagerOnStateChange() to OpenMedia: 
MediaElement State: Opening
TsMediaManager.OpenMediaAsync() state OpenMedia
MediaStreamFascade.MediaManagerOnStateChange() to Opening: 
MediaElement State: Opening
WebContentTypeDetector.GetContentTypeAsync() url ext "http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/playlist.m3u8" type M3U8 

(application/vnd.apple.mpegurl)
...[ommitted for brevity]...
PlaylistSegmentManager.ReadSubList(02/28/2014 00:24:11 +09:00)
PlaylistSegmentManager.ReadSubList() refreshed playlist in 00:00:00.0650532
PlaylistSegmentManager.UpdatePlaylist: playlist http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/chunklist_w689407827.m3u8?

nocache=ff1475c613c1400994e7e97afa26e06c loaded with 250 entries. index: -1 dynamic: False expires: 00:00:00 (02/28/2014 00:24:11 +09:00)
WebContentTypeDetector.GetContentTypeAsync() url ext "http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_0.ts?

nocache=ff1475c613c1400994e7e97afa26e06c" type MPEG-2 Transport Stream (video/MP2T)
TsMediaManager.InitializeMediaParser() for MPEG-2 Transport Stream (video/MP2T)
++++ Starting http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_0.ts?nocache=ff1475c613c1400994e7e97afa26e06c at 02/28/2014 

00:24:11 +09:00.  Total memory: 1.89 MiB
Create PES Video stream (AVC video stream conforming to one or more profiles defined in Annex A of ITU-T Rec. H.264 | ISO/IEC 14496-10 or AVC video sub-

bitstream as defined in 2.1.78) with PID 258
Create PES Audio stream (ISO/IEC 13818-7 Audio with ADTS transport syntax) with PID 259
Configuration H.264 "Baseline" profile, level 3 640x360
TsTimestamp.Update: Sync to start position 00:00:00 at 00:00:10
Configuration AAC layer 0 profile "AAC LC (Low Complexity), 44.1kHz 2 channels" channels 2 sampling 44.1kHz length 26 CRC False
TsTimestamp.Update: Sync to start position 00:00:00 at 00:00:10
BufferingManager.UpdateBuffering: 0.77%, 00:00:00.0696556 duration, 3688 size, 2.93 MiB memory
---- Completed http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_0.ts?nocache=ff1475c613c1400994e7e97afa26e06c at 02/28/2014 

00:24:11 +09:00 (00:00:00.1571120).  Total memory: 3.27 MiB
++++ Starting http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_1.ts?nocache=ff1475c613c1400994e7e97afa26e06c at 02/28/2014 

00:24:11 +09:00.  Total memory: 3.38 MiB
BufferingManager.UpdateBuffering done buffering: 00:00:09.1951000 duration, 309039 size, 3.44 MiB memory
  Video count 223 size 237270 newest 00:00:19.2592556 oldest 00:00:10
  Audio count 133 size 71769 newest 00:00:19.1951000 oldest 00:00:10
WinRtMediaStreamSource.CompleteConfigure()
MediaStreamFascade.MediaManagerOnStateChange() to Playing: 
WinRtMediaElementManager.SetSourceAsync() ME state Closed MM state Playing HasThreadAccess True
WinRtMediaElementManager.SetSourceAsync() post set ME state Opening MM state Playing HasThreadAccess True
MediaElement State: Opening
MediaElement State: Opening
WinRtMediaStreamSource.MediaStreamSourceOnStarting(00:00:00)
WinRtMediaStreamSource.CancelPending()
TsMediaManager.SeekMediaAsync(00:00:00)
MediaElement State: Playing
MediaElement State: Playing
MediaElement State: Playing

...[ommitted for brevity]...

---- Completed http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_5.ts?nocache=ff1475c613c1400994e7e97afa26e06c at 02/28/2014 

00:24:39 +09:00 (00:00:00.0940672).  Total memory: 2.88 MiB
++++ Starting http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_6.ts?nocache=ff1475c613c1400994e7e97afa26e06c at 02/28/2014 

00:24:39 +09:00.  Total memory: 2.89 MiB
BufferingManager.UpdateState read blocking -> False, 00:00:11.9703000 duration 264376 size 3.45 MiB memory
  Video count 287 size 156996 newest 00:01:06.8485111 oldest 00:00:54.8782111
  Audio count 174 size 107380 newest 00:01:06.7495667 oldest 00:00:54.5823111
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
Read of http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_6.ts?nocache=ff1475c613c1400994e7e97afa26e06c failed at 224096: 

Unable to read data from the transport connection: The connection was closed.
'HlsView.Win81.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\Windows\system32\WinMetadata\Windows.Security.winmd'. Module was built without 

symbols.
BufferingManager.UpdateState read blocking -> True, 00:00:25.0250333 duration 657527 size 4.29 MiB memory
  Video count 601 size 432071 newest 00:01:20.1952000 oldest 00:00:55.1701667
  Audio count 360 size 225456 newest 00:01:20.1010444 oldest 00:00:54.9306111
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in SM.Media.DLL
Read of http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_6.ts?nocache=ff1475c613c1400994e7e97afa26e06c failed at 403448: 

Read length mismatch mismatch (179353 expected)
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in SM.Media.DLL
Read of http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_6.ts?nocache=ff1475c613c1400994e7e97afa26e06c failed at 403448: 

Read length mismatch mismatch (1 expected)
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in SM.Media.DLL
Read of http://btnvod.nowcdn.co.kr/btnvod/pogyo/btnsun/mp4:btnsun002.mp4/media_w689407827_6.ts?nocache=ff1475c613c1400994e7e97afa26e06c failed at 403448: 

Read length mismatch mismatch (1 expected)
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in SM.Media.DLL
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
TsMediaManager.CloseMedia()
TsMediaManager.CloseAsync()
MediaStreamFascade.MediaManagerOnStateChange() to Closing: 
MediaElement State: Playing
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
TsMediaManager.ReaderPipeline.StopAsync(): callback reader stop failed: Read length mismatch mismatch (1 expected)
BufferingQueue.ReportFlush(): Video
BufferingQueue.ReportFlush(): Audio
BufferingQueue.ReportDone(): Video
BufferingQueue.ReportDone(): Audio
MediaElement State: Closed
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
TsMediaManager.CloseAsync() completed
A first chance exception of type 'System.AggregateException' occurred in mscorlib.dll
MediaStreamFascade.MediaManagerOnStateChange() to Closed: 
MediaStreamFascade.Stop()
One or more errors occurred.
TaskCollector.Cleanup() task CallbackReader.Close failed: One or more errors occurred.
MediaElement State: Playing
The program '[14100] HlsView.Win81.exe' has exited with code -1 (0xffffffff).
Can this be fixed? :)
Coordinator
Feb 27, 2014 at 8:09 PM
Yes, I think it can be fixed. It looks like a segment is being interrupted somewhere in the middle, which does happen and should not cause any playback trouble. In order to recover, the code does a range read to get the rest of the segment. That part doesn't behave as expected; it looks there may be an off-by-one bug in there somewhere.

At some point, some code should be added that falls back to discarding leading data if the range GET results in a 200 response (the whole file) instead of a 206 response (just the part of the file requested).
Coordinator
Feb 27, 2014 at 8:10 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Feb 27, 2014 at 9:25 PM
Could you see if ea49ce6dc273 works better for you?

Thanks.
Marked as answer by SeongTaeJeong on 3/1/2014 at 6:06 AM
Mar 1, 2014 at 2:06 PM
Thank you henric. Thank you very much. :)

It worked well after applying that.
Coordinator
Mar 1, 2014 at 8:03 PM
That is good to hear.

Thank you for checking.