Hi,
I've seen others have the same problem, and I getting it to, a 504 Gateway Timeout when trying to download this image.
My Gradle is currently setup with these versions of the library...
dependencies {
compile 'com.google.android.gms:play-services:5.2+'
compile 'com.android.support:support-v13:20.0.0'
compile 'com.jakewharton:butterknife:5.1+'
compile 'com.squareup.retrofit:retrofit:1.5+'
compile 'com.squareup.okhttp:okhttp:1.6+'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6+'
compile 'com.squareup.picasso:picasso:2.3+'
compile 'nl.qbusict:cupboard:2.0+'
compile 'com.github.nirhart:parallaxscroll:1.0'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9+'
compile 'com.crashlytics.android:crashlytics:1.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
And I've setup my global Picasso instance like this.
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setReadTimeout(30, TimeUnit.SECONDS);
okHttpClient.setConnectTimeout(30, TimeUnit.SECONDS);
okHttpClient.setProtocols(Arrays.asList(Protocol.HTTP_11));
picasso = new Picasso.Builder(context)
.downloader(new OkHttpDownloader(okHttpClient))
.loggingEnabled(true)
.indicatorsEnabled(true)
.listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception e) {
e.printStackTrace();
}
}).build();
And inside my adapter I'm calling Picasso like this...
mPicasso.load(eventUrl).placeholder(R.drawable.ic_thumb_default).into(holder.imageImageView);
Any pointers on what I might have done wrong would be appreciated.
Regards,
Andy.
I forgot to leave the actual stack trace....
com.squareup.picasso.Downloader$ResponseException: 504 Gateway Timeout
at com.squareup.picasso.OkHttpDownloader.load(OkHttpDownloader.java:108)
at com.squareup.picasso.NetworkBitmapHunter.decode(NetworkBitmapHunter.java:46)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:144)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:101)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
If I switch to using Glide instead of Picasso the image is downloaded successfully, which leads me to believe its a problem with Picasso or okHttp (I'm not using okHttp with Glide at the moment).
This is part of a bigger problem. There is no 504 gateway timeout problem here. There is probably a real exception that gets stomped by Picasso for constantly retrying.
We will figure out a fix.
Thanks for the update and keep up the great work!
Moving to Picasso 2.5.
With #794, a 504 disk cache miss this should no longer stomp the real problem.
Hi all,
i get 504 gateway timeout in picasso version 2.5.2. is it solved in version 2.5.2?
below is the stack trace:
com.squareup.picasso.UrlConnectionDownloader.load (UrlConnectionDownloader.java:95)
com.squareup.picasso.NetworkRequestHandler.load (NetworkRequestHandler.java:47)
com.squareup.picasso.BitmapHunter.hunt (BitmapHunter.java:206)
com.squareup.picasso.BitmapHunter.run (BitmapHunter.java:159)
java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:422)
java.util.concurrent.FutureTask.run (FutureTask.java:237)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:818)
java.lang.Thread.run
com.squareup.picasso.Utils$PicassoThread.run (Utils.java:411)
I have noticed that this issue randomly also occurs using latest picasso library (com.squareup.picasso:picasso:2.71828) if testing device date is not correct or selected the future date.
Strange but i have reproduced this and wasted ample of time.
com.squareup.picasso.NetworkRequestHandler$ResponseException: HTTP 504
at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:51)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:219)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:175)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:354)
Hi I got this issue yesterday when I started using picasso 2.71828. I was also getting 504 gateway timeout. For me the issue was because the header parameters where not getting set. I used the following code and it started working. Hope it helps for someone.
OkHttpClient picassoClient =
new OkHttpClient
.Builder()
.addInterceptor(new Interceptor() {
@Override
public Response intercept(@NonNull Interceptor.Chain chain) throws IOException {
final Request.Builder newRequest = chain.request().newBuilder();
newRequest.addHeader("header_key","header_value");
return chain.proceed(newRequest.build());
}
})
.build();
builder.downloader(new OkHttp3Downloader(picassoClient)).build();
I ran into this issue with Picasso 2.71828 and Android 9 (api 28) because my server was sending the images as cleartext which is not permitted on Android 9. Picasso's logging would result in a 504 error code but if stepped into the network requests the original error was:
"java.net.UnknownServiceException: CLEARTEXT communication to
See this StackOverflow page for more information about the Android Cleartext policy:
https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
The quick "solution" for this issue is to add
android:usesCleartextTraffic="true"
to your Application tag in the Android manifest.
Hi i'm getting same issue when loading target
W/System.err: com.squareup.picasso.NetworkRequestHandler$ResponseException: HTTP 504
at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:51)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:219)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:175)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:354)
it because you use http:// security not permitted in android nougat to pie...make permission in resources/xml make new resources "xml"
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">your domain</domain>
<domain includeSubdomains="true">your domain</domain>
</domain-config>
</network-security-config>
and call in manifest
android:networkSecurityConfig="@xml/network_security_config"
it because you use http:// security not permitted in android nougat to pie...make permission in resources/xml make new resources "xml"
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">your domain</domain>
<domain includeSubdomains="true">your domain</domain>
</domain-config>
</network-security-config>
and call in manifest
android:networkSecurityConfig="@xml/network_security_config"
This solve my issue, Thank you. Cheers! 馃嵒
i was faced same issue now i got solutaion of this. android:usesCleartextTraffic="true" ---> This is main line I hope this work for you..
Just you have go in Androidmanifest.xml and add this line under
android:icon="@mipmap/app_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/app_icon_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
Guys... I'm in a real pain right now... I do have usesClearTextTraffix set to true, but this issue is still occurring. Really super disappointed.
Most helpful comment
it because you use http:// security not permitted in android nougat to pie...make permission in resources/xml make new resources "xml"
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">your domain</domain>
<domain includeSubdomains="true">your domain</domain>
</domain-config>
</network-security-config>
and call in manifest
android:networkSecurityConfig="@xml/network_security_config"