question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR_CODE_IO_BAD_HTTP_STATUS while trying to stream m3u8.

See original GitHub issue

Bug

Problem

I’m trying to stream a m3u8 file in a react native app (for android TV) and I’m getting this error:

 LOG  {"error": {"errorCode": "22004", "errorException": "com.google.android.exoplayer2.ExoPlaybackException: Source error", "errorStackTrace": "com.google.android.exoplayer2.ExoPlaybackException: Source error
	at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
	at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:223)
	at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
	at com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource.open(OkHttpDataSource.java:329)
	at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
	at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
	at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:99)
	at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:62)
	at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:174)
	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)
", "errorString": "ExoPlaybackException: ERROR_CODE_IO_BAD_HTTP_STATUS"}}

I don’t know java so from the above traceback I’m guessing that the server is responding with an HTTP 403 and therefore it is unable to stream the file.

What I’ve tried

  • This one is not much of a solution but I tried switching to the react-native-video-player instead of react-native-video but that didn’t work.
  • I tried passing the type: 'm3u8' and type: 'hls' inside the source attribute of the video tag along with the uri and this didn’t help at all.
  • Tried to check if another m3u8 url (i.e. from another domain/server) is working, and it is working.
  • Downgrading react-native-video version, problem persists with different error message.

I decided to ssh into my android TV and directly use curl to fetch the m3u8 file and it responds with this:

curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

Moreover, many of the issues I found on github having a similar problem contain a URL that gives the same response when fetched directly with curl. Interestingly, if I use the fetch API in JS to console log the response from the m3u8 url, it works perfectly. So I’m guessing the problem is somewhere in exoplayer.

Platform

Which player are you experiencing the problem on:

  • iOS: cannot check
  • Android: problem is here
  • Windows UWP: did not check
  • Windows WPF: did not check

Environment info

React native info output:

 System:
    OS: Linux 5.19 Fedora Linux 36 (Workstation Edition)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 4.93 GB / 7.66 GB
    Shell: 5.2.2 - /bin/bash
  Binaries:
    Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
    Yarn: Not Found
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
    Watchman: 20221016.020512.0 - /usr/local/bin/watchman
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: Not Found
    react-native-tvos:  0.69.6-0 
  npmGlobalPackages:
    *react-native*: Not Found

NOTE I don’t know why it’s saying Java, Android SDK and Android Studio are not installed, I have all of them installed and Android SDK is configured through a local.properties file.

Library version: 6.0.0-alpha.3

Steps To Reproduce

  1. Create a component that returns the following:
    <Video
      style={{flex: 1, width: '100%', height: '100%', backgroundColor: 'green'}}
      source={{uri: url, type: 'm3u8'}} // replace url
      ref={ref => (this.player = ref)}
      onError={err => console.log(err)}
    />
  1. Run the app

Expected behaviour

  1. Video plays and does not give any errors

Reproducible sample code

I think this isn’t really required as there’s nothing much in the code.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
sujaldevcommented, Oct 26, 2022

Nvm found it in the docs, thank you for your help!

0reactions
sujaldevcommented, Oct 26, 2022

For charles trace, please have a look to this page:

Hi, I think I might have figured it out. I used the proxy to see the network request and it seems like exoplayer is setting a user agent parameter in the request which seems to be causing the 403.

image

Do you know how can I remove this header?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playing m3u8 Files with HTML Video Tag - Stack Overflow
I checked that against some Example Playlist Files for use with HTTP Live Streaming, and I don't see any issues. I also tried...
Read more >
How to Get an M3U8 Stream URL Link for Your Live ... - Dacast
Learn how to create an M3U8 live stream URL from a live streaming link. In a few easy steps, you can generate an...
Read more >
Why don't my new m3u8/HLS streams "adapt" - Apple Developer
I have an iOS app which has been in the AppStore for 3+ years. ... the end result is different and when we...
Read more >
How do I play m3u8 files? - stream - Ask Ubuntu
m3u8 files are m3u files encoded in utf8. m3u files are a text based playlist format. You can open the file with any...
Read more >
How to convert mp4 to m3u8 with soft subtitles and audios in ...
This is the kind of m3u8 file, that am trying to generate(this ... what am trying to do is to convert mp4 to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found