picasso: 504 Gateway timeout
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.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16
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"
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 <ServerName> not permitted by network security policy”
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.
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)
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.
i was faced same issue now i got solutaion of this. Just you have go in Androidmanifest.xml and add this line under <application
<application android:allowBackup="true" 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">
android:usesCleartextTraffic=“true” —> This is main line
I hope this work for you…
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();
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)