1
mySimpleDraweeView.setImageURI(Uri.parse("http://cdn.cnn.com:80/cnn/.e1mo/img/4.0/logos/menu_politics.png"));

This is a url from link preview for cnn. It is an http url and not an https url. It has a port :80 in the path.

If I throw that url into a webbrowser, it gets resolved as "http://cdn.cnn.com/cnn/.e1mo/img/4.0/logos/menu_politics.png" and an image is there.

If I try to call setImageURI with "http://cdn.cnn.com/cnn/.e1mo/img/4.0/logos/menu_politics.png" from the web browser, it still doesn't work.

If I try to call setImageURI with "https://cdn.cnn.com/cnn/.e1mo/img/4.0/logos/menu_politics.png" it works.

I'm using a custom OKHttp3 OkHttpClient for Fresco. I tried using the getUnsafeOkHttpClient described here https://stackoverflow.com/a/25992879/1578222, but did not see a change in behavior with it.

I also tried setting the OkHttpClient.followRedirects but it did not fix it either:

httpClient.followSslRedirects(true);
httpClient.followRedirects(true);
CodeSmith
  • 1,621
  • 1
  • 13
  • 31
  • why dont you use the resolved url? – SteelToe Apr 17 '19 at 17:53
  • The resolved url doesn't work either. Also, I need it to work with the urls being given and not just this specific url. The example url from cnn is a problematic url but just an example of one that isn't working. The user is typing in urls for link preview so the values could be anything, I need it to work with whatever is coming back from the link preview request. There is an image behind this url and other components can get it, just not my app's SimpleDraweeView. – CodeSmith Apr 17 '19 at 18:08

1 Answers1

0

I found a log message from the OKHttp3 client and that helped me figure out the problem:

<-- HTTP FAILED: java.net.UnknownServiceException: CLEARTEXT communication to cdn.cnn.com not permitted by network security policy

Solved my changing the Android Manifest file's Application object to include:

android:usesCleartextTraffic="true"
CodeSmith
  • 1,621
  • 1
  • 13
  • 31