Skip to content

Documentation: Accept redirects 301/302 and "Cleartext HTTP traffic to xxx not permitted" #719

Description

@smarek
  • I have verified there are no duplicate active or recent bugs, questions, or requests
Include the following:
  • ExoMedia version: 4.3.0
  • Device OS version: 10.0
  • Devide Manufacturer: Motorola
  • Device Name: Motorola One
Reproduction Steps
  1. Play video from url http://i.imgur.com/SxwNI7f.mp4
Expected Result
  1. ExoMedia should accept the 301 response and redirect to HTTPS version of the linked video
Actual Result
2020-11-10 10:45:15.105 32756-1124/mareksebera.cz.redditswipe E/ExoPlayerImplInternal: Source error.
    com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://i.imgur.com/QljaMs3.mp4
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:281)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:250)
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
        at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:885)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
        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:919)
     Caused by: java.io.IOException: Cleartext HTTP traffic to i.imgur.com not permitted
        at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:124)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:528)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:436)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:279)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:250) 
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83) 
        at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:885) 
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381) 
        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:919) 

I've seen the #691 which touches the same subject, however the solution should be different, than setting usesCleartextTraffic in app manifest

According to docs https://exoplayer.dev/troubleshooting.html#why-do-some-streams-fail-with-http-response-code-301-or-302

If you need to, you can configure ExoPlayer to follow cross-protocol redirects when instantiating DefaultHttpDataSourceFactory instances used in your application. Learn about selecting and configuring the network stack here.

Probably something along the lines of solution in #581, specifically #581 (comment)

I've personally tested this as valid solution

public class MyApplication extends Application {
  @Override
  public function onCreate() {
    super.onCreate();

    ExoMedia.setDataSourceFactoryProvider((userAgent, listener) -> new DefaultHttpDataSourceFactory(userAgent, listener, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, /* allowCrossProtocolRedirects= */ true));
  }
}

So I'd suggest putting up some documentation, and maybe update comment in the #691 so devs do not get advised to allow all cleartext traffic if it's not absolutely necessary

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    • Status
      Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions