Glide: Request failed 404: Not Found

Created on 25 May 2016  Â·  12Comments  Â·  Source: bumptech/glide

Hi,

I'm in a situation where some images don't load, when I use the Request Listener the Error Exception in some images is "Request failed 404: Not Found" as if it wouldn't exist but actually they exist. For example this two images don't load:

http://100.42.52.96/~iosstore/iFishComps/images/90381022016-04-26.jpg (640 × 640)
http://100.42.52.96/~iosstore/iFishComps/images/16846032016-04-26.jpg (638 × 230)

...but for example this one loads perfectly:

http://100.42.52.96/~iosstore/iFishComps/images/86415822016-04-08.jpg (638 × 640)

I have to say that these images load in a browser and also in an IOS app which calls the same requests, although I don't know what library they used to be honest.

Also:

  • My version of Glide is 3.7.0 .
  • I'm using Retrofit to make requests to the server.
  • I am trying to load the images in an imageView, GridView and RecyclerView, all the same result.
  • I have the same result when I test it in a real phone "Aquos" or tablet, or different emulators in Genymotion.
  • I also tried using Piccaso, but the result is just the same regarding this issue.

This is the part of the code where I used Glide:

``` @Override
public void onBindViewHolder(ViewHolder viewHolder, final int position) {

    Glide
            .with(context)
            .load(vectorImage[position])
            .asBitmap()
            .placeholder(android.R.color.holo_green_light)
            .error(android.R.color.holo_red_light)
            .fallback(android.R.color.holo_orange_light)
            .listener(new RequestListener<String, Bitmap>() {
                @Override
                public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
                    Log.i("harol", "Error:"+ String.valueOf(e));
                    return false;
                }

                @Override
                public boolean onResourceReady(Bitmap resource, String model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    ImageViewTarget imTarget = (ImageViewTarget) target;
                    return new DrawableCrossFadeFactory<>()
                            .build(isFromMemoryCache, isFirstResource)
                            .animate(new BitmapDrawable(imTarget.getView().getResources(), resource), imTarget);
                }
            })
            .into(viewHolder.getHolderImage());

}

This is the XML view that contains the image:

     <au.com.myapp.android.customViews.CustomSquaredImage
            android:id="@+id/image_comp"
            android:layout_width="match_parent"
            android:scaleType="fitXY"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal" />

This is the CustomImageView:

public class CustomSquaredImage extends ImageView {

public CustomSquaredImage(Context context) {
    super(context);
}

public CustomSquaredImage(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public CustomSquaredImage(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}


@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}

}


A screen shot that shows the red ones when an error occurs:

![screen shot 2016-05-26 at 01 17 20](https://cloud.githubusercontent.com/assets/13315485/15547645/a88fe82c-22df-11e6-8c77-cfc7bf5828e0.png)

The logcat:

I/harol: Error:java.io.IOException: Request failed 404: Not Found
I/harol: Error:java.io.IOException: Request failed 404: Not Found
I/harol: Error:java.io.IOException: Request failed 404: Not Found
I/harol: Error:java.io.IOException: Request failed 404: Not Found
I/harol: Error:java.io.IOException: Request failed 404: Not Found
I/harol: Error:java.io.IOException: Request failed 404: Not Found
I/harol: Error:java.io.IOException: Request failed 404: Not Found
```

I would really appreciate an advice.

Thanks

non-library question

Most helpful comment

Make sure your URL doesn't contain extra space. I had space issue as
library doesn't trim the space

On Fri, 7 Apr 2017 at 00:44, Manu Sharma notifications@github.com wrote:

@meet2011 https://github.com/meet2011 did you find the solution for
your problem. I am facing same issue.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bumptech/glide/issues/1235#issuecomment-292282250,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALmDtDukgDL1s0gCYpODhOtpjD_eo3n3ks5rtTl4gaJpZM4Imtqb
.

>

Sent from iPhone

All 12 comments

This looks like a SO question because it's consistent across Android phones, even different libraries. This consistency may also suggest that the server simply rejects Android requests, the weird thing is that only some. Rejecting some requests may be because of rate limiting, which again is probably not true because you tried to load in a single imageview.

When you say you're using Retrofit do you mean that you wrote an integration library for Glide to replace the default networking? If so, try to use the built-in and/or OkHttp3 to see if it makes a difference. Even if not changing to OkHttp is worth a try.

The variable name is vectorImage, but these are JPGs, or does vector just means a list in this case?

Try to add an extra argument , e to Log.i's last argument. The cause in the stack trace may shed some light on what's going on.

Tip: in 3.8.0-SNAPSHOT there is .asBitmap().crossFade().

@TWiStErRob I am getting 404 Request Failed error

Request failed 404: Not Found
java.io.IOException: Request failed 404: Not Found
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:90)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:44)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:20)
at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:70)
at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:53)
at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:170)
at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)
at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)
at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)
at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)

Image URL : http://portal2.shipeliteexpress.com/images/BannerImageEliteExpress/orionfreightelite_banner1_20160223061104.png

@TWiStErRob can you help to fix the issue?

@meet2011 not really, I tried loading the url you provided and it works on Desktop Chrome, Android Chrome and through Glide as well.

_I'm having a similar issue though: I could not access my website on my devices for days, but everyone outside my house has said "it works" so far. Now, just as I was writing this it started working on my phone, but still doesn't work on my laptop. I suspect some DNS or similar issue._

@meet2011 did you find the solution for your problem. I am facing same issue.

Make sure your URL doesn't contain extra space. I had space issue as
library doesn't trim the space

On Fri, 7 Apr 2017 at 00:44, Manu Sharma notifications@github.com wrote:

@meet2011 https://github.com/meet2011 did you find the solution for
your problem. I am facing same issue.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bumptech/glide/issues/1235#issuecomment-292282250,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALmDtDukgDL1s0gCYpODhOtpjD_eo3n3ks5rtTl4gaJpZM4Imtqb
.

>

Sent from iPhone

@meet2011 You are life saver man. Thanks a lot. It worked.

Huh, that't simpler than a DNS issue :)
Out of curiosity where are you getting invalid urls that contain spaces?

@TWiStErRob I have seen earlier that when there is an space at the end of URL it throws 404 not found error.

@TWiStErRob Third party servers send these things as strings. Lesson learned "Always trim your urls"

@47sharmamanu Yikes, you should really report this to that third party.

No URL should be trimmed, especially when you're not parsing it out from some text. For example if you get a JSON like { "image": "http://...." }, you should never be forced to revalidate that url and trim and do other stuff to it.

I did report the issue and they might be working on it.But just for future
reference I'll just keep a check on it.

On 9 Apr 2017 4:30 p.m., "Róbert Papp" notifications@github.com wrote:

@47sharmamanu https://github.com/47sharmamanu Yikes, you should really
report this to that third party.

No URL should be trimmed, especially when you're not parsing it out from
some text. For example if you get a JSON like { "image": "http://...." },
you should never be forced to revalidate that url and trim and do other
stuff to it.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bumptech/glide/issues/1235#issuecomment-292778822,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AK1EMkFESZdksjxsChEi0rg7eHgXwxh1ks5ruLpggaJpZM4Imtqb
.

Was this page helpful?
0 / 5 - 0 ratings