Baseflow / flutter_cached_network_image

Download, cache and show images in a flutter app
https://baseflow.com
2.41k stars 640 forks source link

CacheManager: Failed to download file from url #336

Open sandeep9607 opened 4 years ago

sandeep9607 commented 4 years ago

cached_network_image: ^2.0.0

I/flutter (23961): CacheManager: Failed to download file from http://host/images/a.png with error: I/flutter (23961): SocketException: Failed host lookup: 'host' (OS Error: No address associated with hostname, errno = 7)

sandeep9607 commented 4 years ago

Flutter 1.12.13+hotfix.7

Any help would be appreciable. Thanks

samuelematias commented 4 years ago

I'm have the same issue:

flutter: CacheManager: Failed to download file from https://static-images.api.com.br/image/upload/f_auto,t_thumbnail/icones/pgto/******** with error: HttpException: No valid statuscode. Statuscode was 404

Flutter Version: Flutter 1.12.13+hotfix.7 • channel stable • https://github.com/flutter/flutter.git Framework • revision 9f5ff2306b (2 weeks ago) • 2020-01-26 22:38:26 -0800 Engine • revision a67792536c Tools • Dart 2.7.0

Plugin Version: cached_network_image: ^2.0.0

taekungkub commented 4 years ago

i have this same problam

renefloor commented 4 years ago

@sandeep9607 @samuelematias or @taekungkub can any of you give me a valid URL that does load in the browser (and doesn't give a 404), but does not load in the CachedNetworkImage?

dodancs commented 4 years ago

I have some similar issue:

CacheManager: Failed to download file from URL with error:
  type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic'

First time using the package, it took like 5 reloads of my app to successfully display the image...

dodancs commented 4 years ago

I have some similar issue:

CacheManager: Failed to download file from URL with error:
  type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic'

First time using the package, it took like 5 reloads of my app to successfully display the image...

  • Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.720], locale sk-SK)
  • cached_network_image: ^2.0.0

This only happened when using an Emulator to run my app. When I switched to my physical device, the errors did not appear.... this is strange. I also tried disabling Proxy settings on the android emulator, but with no change.

jawad12345A commented 4 years ago

Does anyone solved this issue?

renefloor commented 4 years ago

@dodancs that is really strange, as far as I know an emulator works the same as a physical device.

dodancs commented 4 years ago

@renefloor Doesn't seem like it. I'm not sure what could be causing this. But I spent a lot of hours trying to fix my "broken code" to only realize it was because of the emulator. I also never seen anything like this before.

jawad12345A commented 4 years ago

@renefloor Doesn't seem like it. I'm not sure what could be causing this. But I spent a lot of hours trying to fix my "broken code" to only realize it was because of the emulator. I also never seen anything like this before.

It is also happening on physical phone too

hasanzia1993 commented 4 years ago

same issue CacheManager: Failed to download file from ...

DhavalRKansara commented 4 years ago

is there any solution for this or I also have to write "the SAME ISSUE"

hasanzia1993 commented 4 years ago

same issue CacheManager: Failed to download file from ...

It actually is working fine for me now, my URL was not returning any data first. Could be something else for other but for me it's working perfectly fine now.

renefloor commented 4 years ago

is there any solution for this or I also have to write "the SAME ISSUE"

@DhavalRKansara you could help in looking for a solution. I don't know why files sometimes fail to download, as I still don't have a reproducible example of an url that should work but doesn't

DhavalRKansara commented 4 years ago

@renefloor Actually You guys can add one null and empty check before network request for the image and if image URL is null then simply show the placeholder image means no need to do network request for null image URL.

Because in my case I have some image URL as null or empty and then I am getting the error:

flutter: CacheManager: Failed to download file from null with error:
Invalid argument(s): No host specified in URI null
renefloor commented 4 years ago

Hmm, not sure if I agree with that. Why the placeholder and not the error widget? I would expect an error when the image is null. What is your usecase that null is a valid image?

DhavalRKansara commented 4 years ago

Hmm, not sure if I agree with that. Why the placeholder and not the error widget? I would expect an error when the image is null. What is your use case that null is a valid image?

Yeah totally agree we can show error image In case of null or empty image URL.

DhavalRKansara commented 4 years ago

This is really Strange, Now I am also facing the same issues while downloading the images.

In my case, I have to pass httpHeader with AuthToken to download the image using this library. Also, I am getting the error every time sometimes it successfully download the image and sometimes it gives the below error. It's really strange.

flutter: CacheManager: Failed to download file from https://*****?imageName=jpg file.jpg&path=Patient_Documents\ with error:
HttpException: Invalid statusCode: 500, uri = https://*****?imageName=jpg%20file.jpg&path=Patient_Documents%5C

@renefloor Have you faced the error in any example?

renefloor commented 4 years ago

@DhavalRKansara a statusCode 500 normally is something going wrong on the server. I guess you have to discuss this with the backend developer. I don't know if you have content with him/her?

DhavalRKansara commented 4 years ago

@DhavalRKansara a statusCode 500 normally is something going wrong on the server. I guess you have to discuss this with the backend developer. I don't know if you have content with him/her?

@renefloor Yes I have discussed with my backend developer and also for the same URL I have tried to get an image through the postman and I successfully get the image in postman. That's why I am saying that not every time I got failed to download network image it's 50-50 scenario and still I'm looking into it with different testing scenarios.

DhavalRKansara commented 4 years ago

cached_network_image: ^2.0.0

I/flutter (23961): CacheManager: Failed to download file from http://host/images/a.png with error: I/flutter (23961): SocketException: Failed host lookup: 'host' (OS Error: No address associated with hostname, errno = 7)

Please check the image file url carefully... Because I don't found any image for the given url.

ivenxu commented 4 years ago

In my case, add

<uses-permission android:name="android.permission.INTERNET"/>

to android/app/src/main/AndroidManifest.xml worked.

hahazheng commented 4 years ago

@renefloor @DhavalRKansara

flutter: CacheManager: Failed to download file from http://mt3.google.com/vt/lyrs=m&x=32752&y=21795&z=16 with error: SocketException: OS Error: Operation timed out, errno = 60, address = mt3.google.com, port = 52998 Example url: http://mt3.google.com/vt/lyrs=m&x=32752&y=21795&z=16

renefloor commented 4 years ago

Operation timed out sounds like a bad internet connection.

cargallo commented 4 years ago

image

image

Same Issue here! I want to test whats would happen if the url is wrong. In the case of firebase storage it returns 403. But the problem is thtat I don't know why the debugger is stopping there since I think it should be a Controlled Exception..

renefloor commented 4 years ago

@cargallo That's an issue of the Dart VM, it doesn't always know if an exception is uncaught or not. See https://stackoverflow.com/questions/56802675/dart-flutter-debugger-stops-on-caught-exceptions

It should not break your app.

cargallo commented 4 years ago

Tnx @renefloor I didn't knew that. Also I'm facing issues with the use of try catch and Futures and Error handling in Flutter, plus your comment I asume that Dart is some kind of immature in this context.

renefloor commented 4 years ago

You can call it immature, but seeing the conversation on github about this I would not expect it to change soon if ever.

renefloor commented 4 years ago

I don't think this is really a bug in the library

marcjoha commented 4 years ago

@renefloor I don't fully understand this issue, so this might be unfeasible, but any chance this library could benefit from the advice in https://github.com/flutter/flutter/issues/33427#issuecomment-523615622?

mikydemewoz commented 4 years ago

I was having the same problem while running in real mobile device so the problem was that I was not connecting with the internet so that is all I fix

greg-fischer commented 4 years ago

I ran into this issue once I tried loading the 2.3.0-rc version to test. Once I did, the app hangs in emulator any time a I hit a 404 on an image. I wasn't getting any errors in vscode debug. But then I enabled All Exceptions and saw it break in flutter_cache_manager 1.4.1 in web_helper.dart line 84. It shows "Invalid statusCode: 404".

Its not a connection issue, or at least that doesn't make sense when other images load fine from same server and when its always the same missing files. Its only when I hit an actual 404, the file isn't on the server. I just downgraded back to 2.2.0+1 and still get crashes now. Not sure what to do to get the app running correctly again, and I don't know how to error trap in the widget code.

Edit: App runs fine now, just needed to uncheck "Uncaught Exceptions". But I do see lots of HttpExceptions with that error in DevTools. Also, not relevant to this issue, but I had to delete all the pubspec cache directories and the pubspec.lock file to get rid of the 2.3.0-rc version, which kept coming back, confusing me even further.

aniteshreddy commented 3 years ago

did anyone found the way out for this problem??

Jayant-BL commented 3 years ago

CacheManager: Failed to download file from https://kc-vendor-qa.s3.ap-south-1.amazonaws.com/user/42/profile/mh6SAE4fBjU6lNeM5hV9vw4pjZB81QyU1xJjZlVy.jpeg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZQBUL2OKXSTRB5O6%2F20200729%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20200729T074210Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3300&X-Amz-Signature=e3709a8df5b74a6fbe61f1510957c05015d3b79f4246fd90c0c5c738c8523340 with error:

I/flutter (15558): Connection closed before full header was received I/flutter (15558): inside errorConnection closed before full header was received

Here's for better understanding. This image URL on browser opens the image, however, this exact URL opens image almost 9/10 times with CachedNetworkImage

furkanvatandas commented 3 years ago

Same issue, the image url return 404

gustavo-perini commented 3 years ago

Same issue here. Connection closed before full header was received.

whatamelon commented 3 years ago

Same issue. When I request many images such as 30 images within api, connection closed and a little images returned error.

khalid-alsaleh-dev commented 3 years ago

@gustavo-perini @Jayant-BL @whatamelon Did you figure it out ?

ysabuna commented 3 years ago

Same error.

Jayant-BL commented 3 years ago

@gustavo-perini @Jayant-BL @whatamelon Did you figure it out ?

Still searching for a solution.

gustavo-perini commented 3 years ago

Not yet.

On Fri, Sep 4, 2020 at 8:30 AM Jayant Choudhary notifications@github.com wrote:

@gustavo-perini https://github.com/gustavo-perini @Jayant-BL https://github.com/Jayant-BL @whatamelon https://github.com/whatamelon Did you figure it out ?

Still searching for a solution.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter_cached_network_image/issues/336#issuecomment-687087763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOCMPJVSLTTLH57ZUUEBFITSEDFUFANCNFSM4KT2WEOA .

habib671 commented 3 years ago

solved it guys! your imageUrl is getting null.. just check if it is not null then return CachedNetImage otherwise return a container using ternary operator ::

child: photoUrl!=null ? CachedNetworkImage( placeholder: (context,photo)=>Container( child: CircularProgressIndicator( strokeWidth: 2.0, valueColor: AlwaysStoppedAnimation(Colors.lightBlueAccent), ), width: 200.0, height: 200.0, padding: EdgeInsets.all(20.0), ), imageUrl: photoUrl, width: 200.0, height: 200.0, fit: BoxFit.cover, ) : Container(),

habib671 commented 3 years ago

@renefloor Actually You guys can add one null and empty check before network request for the image and if image URL is null then simply show the placeholder image means no need to do network request for null image URL.

Because in my case I have some image URL as null or empty and then I am getting the error:

flutter: CacheManager: Failed to download file from null with error:
Invalid argument(s): No host specified in URI null

solved it guys! your imageUrl is getting null.. just check if it is not null then return CachedNetImage otherwise return a container using ternary operator ::

child: photoUrl!=null ? CachedNetworkImage( placeholder: (context,photo)=>Container( child: CircularProgressIndicator( strokeWidth: 2.0, valueColor: AlwaysStoppedAnimation(Colors.lightBlueAccent), ), width: 200.0, height: 200.0, padding: EdgeInsets.all(20.0), ), imageUrl: photoUrl, width: 200.0, height: 200.0, fit: BoxFit.cover, ) : Container(),

whatamelon commented 3 years ago

I just solved with image url https -> http. I think flutter's decoding image codec with https logic is too slow or not perfect when get many images. So, problem can produce like me.

Well, I think this is not a solution for every piece of problem with this issue. Hope it will be a solution for getting problem like me.

bhanuka96 commented 3 years ago

any solution?

z234009184 commented 3 years ago

any solution?

fullflash commented 3 years ago

same here.

QueryHaqi commented 3 years ago

reload another image solved for me

geanlima commented 3 years ago

Flutter 1.12.13+hotfix.7

Any help would be appreciable. Thanks

In my case, I updated cached_network_image to version ^ 2.4.1.

alperenarc commented 3 years ago

Same issue here ! CacheManager: Failed to download file from with error: Invalid argument(s): No host specified in URI

There is no problem on UI. Images loaded but I tought an error.