This project has moved. For the latest updates, please go here.

Response status code does not indicate success: 406 (Not Acceptable).

Oct 12, 2014 at 2:46 PM
Hello!
I'm trying to use your source code to port an existing iOS/Android app to WP8.

I have a m3u8 stream on a server which is currently working and running for iOS and Andorid, but when I put that m3u8 link into NasaTv sample project. I got "3018 Unable to play media" error.

Digging the output log, I saw this line:

Response status code does not indicate success: 406 (Not Acceptable).

Which might mean that the output sent from the server is not what the client expects.

I noticed that the server from nasa returns type
audio/x-mpegurl
while my server returns
application/x-mpegurl

Do you think that having my server to return audio/x-mpegurl might fix the issue? Or do you have any other suggestion/idea?

Thank you in advance for you help

Davide
Coordinator
Oct 12, 2014 at 3:38 PM
You might want to compare what phonesm is doing to what a working implementation is doing on the network. That 406 is probably coming back from your server, so what is in the client's outgoing "Accept:" header is probably more important that what is coming back from the server. To see what is happening on the network, Wireshark and Fiddler can both be helpful here; the latter is usually easier to use.

The first thing that comes to mind is that phonesm ignores cookies unless you tell it otherwise. To enable them, you can do something like this (before trying to play anything):
    _mediaStreamFacade.SetParameter(new HttpClientFactoryParameters { CookieContainer = new CokieContainer() });
The error you describe from the output does not suggest that there is a problem with the format on the client side, but if you do run into a problem auto-detecting the content type, you can bypass the detection logic like so:
    _mediaStreamFacade.ContentType = ContentTypes.M3U8;
Note that depending on the version of the code you are using, you may need to use "fascade" instead of "facade". Pardon the typo...
Oct 14, 2014 at 6:16 PM
Hello henric,
thank you for your fast reply!

I've tried to add both the lines you suggested but still I got the same error.

here's the full log after I click the play button:
Play clicked
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\Data\Programs\{61F1B892-D57C-4609-A476-ECBF61B93AD5}\Install\SM.Media.Web.HttpClientReader.DLL' completato. Simboli caricati.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Net.Primitives.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Threading.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\Data\Programs\{61F1B892-D57C-4609-A476-ECBF61B93AD5}\Install\SM.Media.Builder.DLL' completato. Simboli caricati.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\Data\Programs\{61F1B892-D57C-4609-A476-ECBF61B93AD5}\Install\Autofac.DLL' completato. Impossibile trovare o aprire il file PDB.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Collections.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Linq.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Diagnostics.Debug.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
MediaStreamFacadeBase.CloseMediaAsync()
MediaStreamFacadeBase.CloseMediaAsync() completed
MediaStreamFacadeBase.OpenMediaAsync(http://ec2-54-72-50-212.eu-west-1.compute.amazonaws.com/anfiteatrum/it/android/costruzione/video1/prog_index.m3u8)
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\Data\Programs\{61F1B892-D57C-4609-A476-ECBF61B93AD5}\Install\SM.TsParser.DLL' completato. Simboli caricati.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Runtime.Extensions.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.IO.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\Data\Programs\{61F1B892-D57C-4609-A476-ECBF61B93AD5}\Install\System.Net.Http.DLL' completato. Impossibile trovare o aprire il file PDB.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\Data\Programs\{61F1B892-D57C-4609-A476-ECBF61B93AD5}\Install\System.Net.Http.Primitives.DLL' completato. Impossibile trovare o aprire il file PDB.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'Anonymously Hosted DynamicMethods Assembly' completato. 
TsMediaStreamSource.OpenMediaAsync()
Media OpenMediaAsyncCalled: Idle -> Opening at 14/10/2014 18:54:52 +02:00
TsMediaManager.OpenMedia()
TsMediaManager.OpenMedia() handler
MediaElement State: Opening
MediaStreamFacadeBase.MediaManagerOnStateChange() to OpenMedia: 
MediaElement State: Opening
MediaElement State: Opening
TsMediaManager.OpenMediaAsync() state OpenMedia
MediaStreamFacadeBase.MediaManagerOnStateChange() to Opening: 
MediaElement State: Opening
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): caricamento di 'C:\windows\system32\System.Net.Requests.ni.dll' completato. Caricamento dei simboli ignorato. Il modulo è ottimizzato e l'opzione del debugger 'Solo codice utente' è abilitata.
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in System.Net.Http.DLL
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in SM.Media.DLL
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
PlaylistSegmentManagerFactory.SetMediaSource(): unable to load playlist: Response status code does not indicate success: 406 (Not Acceptable).
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in SM.Media.DLL
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
Eccezione first-chance di tipo 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll
TsMediaManager.OpenMediaAsync failed: Response status code does not indicate success: 406 (Not Acceptable).
Eccezione first-chance di tipo 'System.AggregateException' in SM.Media.DLL
Eccezione first-chance di tipo 'System.AggregateException' in mscorlib.ni.dll
AsyncFifoWorker.WorkHandle.RunAsync() work should not throw exceptions: System.AggregateException: Response status code does not indicate success: 406 (Not Acceptable).
   System.Net.Http.HttpRequestException: Response status code does not indicate success: 406 (Not Acceptable).
   System.Net.Http.HttpRequestException: Response status code does not indicate success: 406 (Not Acceptable).

MediaStreamFacadeBase.MediaManagerOnStateChange() to Error: Unable to play media
MediaElement State: Opening
TsMediaStreamSource.CloseMedia()
Media CloseMediaCalled: Opening -> Closing at 14/10/2014 18:54:56 +02:00
TsMediaStreamSource.CloseMediaHandler()
MediaStreamFacadeBase.RequestStop()
TsMediaManager.CloseMedia()
MediaStreamFacadeBase.CloseMediaAsync()
MediaPlayerSource.CloseMediaAsync() calling mediaManager.CloseAsync()
MediaElement State: Closed
TsMediaManager.CloseAsync()
TsMediaManager.CloseAsync()
TsMediaManager.CloseAsync() calling _mediaStreamSource.CloseAsync()
TsMediaStreamSource.CloseAsync(): open 0 close RanToCompletion
MediaStreamFacadeBase.MediaManagerOnStateChange() to Closed: 
MediaElement State: Closed
TsMediaManager.CloseAsync() completed
TsMediaManager.CloseAsync() completed by other caller
MediaPlayerSource.CloseMediaAsync() returned from mediaManager.CloseAsync()
MediaStreamFacadeBase.CleanupMediaManager()
TsMediaManager.Dispose()
TsMediaManager.CloseAsync()
TsMediaManager.CloseAsync() completed by other caller
TsMediaManager.Dispose()
TsMediaStreamSource.Dispose()
Media DisposeCalled: Closing -> Idle at 14/10/2014 18:54:57 +02:00
Il thread 0xa14 è terminato con il codice 259 (0x103).
MediaStreamFacadeBase.CleanupMediaManager() completed
MediaStreamFacadeBase.CloseMediaAsync() completed
The first line that seems to fail contains:
PlaylistSegmentManagerFactory.SetMediaSource(): unable to load playlist: Response status code does not indicate success: 406 (Not Acceptable).
Could the problem be that I do not manage playlists at all on my server? I just have a single m3u8 to reproduce.

By the way, I've also tried with Apple standard test stream, and it's working.

Do you have any other suggestion? What should I look at using Fiddle?

Thanks,

Davide
Coordinator
Oct 14, 2014 at 8:52 PM
Take a look at the request headers for both devices with Fiddler (iPhone and Windows Phone). There is something about the request from phonesm that the server doesn't like. Once you do have both requests, you should be able to drag the WP request to Fiddler's "Composer" tab, and modify it to look more like the iPhone request until it works. Pay particular attention to the "Accept" header in the request.

If you have access to the server, take a look at the server logs to see if there are any error messages from your requests.

You might also try running the HlsView.Win81 or SamplePlayer (a console app) to see if they behave differently.

When we know what needs to change in the request headers (it is probably safe to assume that it is something in the request headers), it should be simple enough to fix.

BTW, you might also try a request with "M3U" instead of "M3U8",
_mediaStreamFacade.ContentType = ContentTypes.M3U;
That should send an "Accept:" with "application/x-mpegURL" instead of "application/vnd.apple.mpegurl" (depending on the exact version of phonesm you are using).
Coordinator
Oct 25, 2014 at 1:21 AM
d18962d69356 and aa213e5c36d5 should help, without any need for forcing the ContentType.