alpha0010 / react-native-file-access

Filesystem access for React Native
MIT License
298 stars 18 forks source link

fetch: Failed to connect to localhost/127.0.0.1:PORT #76

Open lucaslenz opened 9 months ago

lucaslenz commented 9 months ago

react-native: 0.72.4 react-native-file-access: 3.0.4 Platform: Android

Bug I am using react-native-image-cache which utilizes this library. I am running in some errors on android when trying to load an image. I get the error from this call (FileSystem.fetch) with the following arguments:

source:  http://localhost:3000/some/path/over/here?someQueryParameter=true
path:  /data/user/0/<app-identifier>/cache/<...>/images/1d331f734be348d78fe4a71a2f8aeb4493a14338.jpg

The error message i get is

Maximum retries exceeded: Failed to connect to localhost/127.0.0.1:3000

This error is android only and also only occurs with the given parameters. When using another image and hence other parameters it's just working fine. I don't know if I'm missing anything but it seems like a bug. Working for the following parameters:

source: https://images.pexels.com/photos/36717/amazing-animal-beautiful-beautifull.jpg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1
path: /data/user/0/<appp-identifier>/cache/pingr/images/3486045310072102e400cc40bcab227cd0a7811a.jpg

The image does exist btw. and loads on iOS.

lucaslenz commented 8 months ago

I just found out that it was my fault.

For everyone having the same issue you need to remap localhost to 10.0.2.2 when running in android emulator.