ERROR_CODE_IO_BAD_HTTP_STATUS while trying to stream m3u8.
See original GitHub issueBug
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 ofreact-native-video
but that didn’t work. - I tried passing the
type: 'm3u8'
andtype: '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
- 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)}
/>
- Run the app
Expected behaviour
- 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:
- Created a year ago
- Comments:6
Nvm found it in the docs, thank you for your help!
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.
Do you know how can I remove this header?