picasso: Picasso not loading images from https urls

Hi,

I’m running a simple test where I try to get a photo from Flickr like so:

Picasso.with(context)
    .load("https://farm6.staticflickr.com/5294/5460063960_1ef2d5c216_o.jpg")
            .resize(width, height)
            .into(target);

Problem is, if I use https, the loading fails with a timeout. It doesn’t happen if I use http instead. Is there any config setting I could use or something else that can be done or that I am missing? Below is the stack trace.

Thank you!

java.net.SocketTimeoutException: Read timed out at com.squareup.okhttp.internal.spdy.SpdyStream$SpdyDataSource.waitUntilReadable(SpdyStream.java:417) at com.squareup.okhttp.internal.spdy.SpdyStream$SpdyDataSource.read(SpdyStream.java:368) at com.squareup.okhttp.internal.http.SpdyTransport$SpdySource.read(SpdyTransport.java:268) at com.squareup.okhttp.internal.okio.RealBufferedSource$1.read(RealBufferedSource.java:168) at java.io.InputStream.read(InputStream.java:163) at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142) at java.io.BufferedInputStream.read(BufferedInputStream.java:309) at com.squareup.picasso.MarkableInputStream.read(MarkableInputStream.java:138) at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:664) at com.squareup.picasso.NetworkBitmapHunter.decodeStream(NetworkBitmapHunter.java:108) at com.squareup.picasso.NetworkBitmapHunter.decode(NetworkBitmapHunter.java:60) at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:123) at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:83) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856) at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:306)

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 24 (5 by maintainers)

Most upvoted comments

We charge $10 to enable HTTPS.

On Sun, May 10, 2015, 9:20 AM tamawy notifications@github.com wrote:

Use Universal Image Loader instead. It supports HTTPS by default https://github.com/nostra13/Android-Universal-Image-Loader

— Reply to this email directly or view it on GitHub https://github.com/square/picasso/issues/500#issuecomment-100640546.

This might be a bug in the SPDY support of OkHttp and how Flickr’s servers behave. You can disable SPDY with this:

OkHttpClient client = new OkHttpClient();
client.setProtocols(Arrays.asList(Protocol.HTTP_11));
Picasso picasso = new Picasso.Builder(context)
    .downloader(new OkDownloader(client))
    .build();

Downside here is that you have to carry that picasso reference around your app rather than using Picasso.with(context).

We should really provide a way to configure the global singleton…

@alikamts with that combination of dependencies you probably need something more like

final OkHttpClient client = new OkHttpClient.Builder()
        .protocols(Collections.singletonList(Protocol.HTTP_1_1))
        .build();

final Picasso picasso = new Picasso.Builder(this)
        .downloader(new OkHttp3Downloader(client))
        .build();

Picasso.setSingletonInstance(picasso);

where the OkHttp3Downloader instance is supplied by this library.

First, I’d like to thank you for your response. Second, don’t make jokes with me again 😄. Third, someone on StackOverFlow asked a question about the same issue and on of the answer was recommending to him to implement TrustAllCerts and initialize the instance with it ( http://stackoverflow.com/a/26398617/1364896). I will expect that this is right, but if you think I should do something else or something missing, let me know please. Thanks again.

BTW, you, personally, were the center of a conversation between some Android developers few weeks ago in Android development conference in Dubai 😃

On Thu, May 21, 2015 at 6:53 AM, Jake Wharton notifications@github.com wrote:

I was making a joke.

Picasso does not have an HTTP client inside of it so saying that is “supports HTTPS” means little. When you pass in a url (whether it has a scheme of http:// or https://) we pass that along to the most appropriate HTTP client there is. Maybe that’s java.net.HttpURLConnection. Maybe it’s that sexy bundle of bytecode OkHttp. The bottom line is that whatever the scheme is we just let the HTTP client handle it. Any problems you are having with http:// vs https:// are in the configuration of the client, not Picasso.

— Reply to this email directly or view it on GitHub https://github.com/square/picasso/issues/500#issuecomment-104108875.

Regards,

Sami El-Tamawy Software engineer Insydo Dubai, UAE Mobile: (+971) 52565 9772 Skypid: a.s.tamawy

Hey guys I have made CustomPicasso gist which supports image URL redirection using @JakeWharton’s picasso2-okhttp3-downloader

CustomPicasso gist - https://gist.github.com/hrishikesh-kadam/09cef31c736de088313f1a102f5ed3a3

Usage -

CustomPicasso.with(context)
    .load("http://i.imgur.com/DvpvklR.png")
    .into(imageView);