Expo android network request failed

Содержание
  1. Network request failed (device and emulator) #1606
  2. Comments
  3. viniciuscastelano commented Apr 4, 2018
  4. ide commented Apr 4, 2018
  5. ljtijhuis commented Apr 23, 2018
  6. aprilmintacpineda commented May 1, 2018
  7. aprilmintacpineda commented May 1, 2018
  8. aprilmintacpineda commented May 1, 2018
  9. aprilmintacpineda commented May 1, 2018
  10. aprilmintacpineda commented May 2, 2018 •
  11. Network request failed android (emulator and device) #5469
  12. Comments
  13. ms4ever7 commented Aug 28, 2019
  14. 🐛 Bug Report
  15. Environment
  16. Steps to Reproduce
  17. cruzach commented Aug 28, 2019
  18. ms4ever7 commented Aug 28, 2019
  19. cruzach commented Aug 28, 2019
  20. ms4ever7 commented Aug 29, 2019 •
  21. cruzach commented Aug 29, 2019
  22. Chasty commented Oct 7, 2019
  23. eyeamkd commented Oct 7, 2019
  24. rodriguezmanu commented Oct 7, 2019
  25. onlyargon commented Oct 28, 2019
  26. cruzach commented Oct 28, 2019
  27. onlyargon commented Oct 28, 2019
  28. onlyargon commented Oct 29, 2019
  29. yatagan commented Oct 30, 2019
  30. ThiagoLAMF commented Oct 31, 2019
  31. yatagan commented Oct 31, 2019
  32. onlyargon commented Nov 2, 2019
  33. cruzach commented Nov 4, 2019
  34. ms4ever7 commented Feb 25, 2020
  35. nfabacus commented May 10, 2020
  36. yemialpha commented Jul 1, 2020
  37. obie3 commented Sep 16, 2020
  38. xgenem commented Oct 22, 2020 •
  39. brentvatne commented Oct 22, 2020
  40. TypeError: Network request failed when fetching a file:// uri #2402
  41. Comments
  42. 0xori commented Oct 11, 2018
  43. Environment
  44. Steps to Reproduce
  45. Expected Behavior
  46. Actual Behavior
  47. Some Code
  48. nebmesemaou commented Oct 11, 2018
  49. 0xori commented Oct 14, 2018
  50. Cheonsoon commented Nov 6, 2018
  51. moxorama commented Nov 7, 2018
  52. DhirajKate commented Nov 13, 2018
  53. 0xori commented Nov 13, 2018
  54. sjchmiela commented Nov 22, 2018
  55. edzillion commented Nov 23, 2018
  56. romines commented Dec 2, 2018
  57. sjchmiela commented Dec 3, 2018

Network request failed (device and emulator) #1606

Comments

viniciuscastelano commented Apr 4, 2018

I am getting the error «Network request failed» (device and emulator) while accessing the URL https://reqweb.cast.com.br:5443/RequerimentoRest/req/login via fetch (). I can access this link via Postman or browser normally.

I wonder if there is a solution for this.

Thank you very much in advance.

The text was updated successfully, but these errors were encountered:

ide commented Apr 4, 2018

The port for HTTPS is typically 443, you may want to double-check that. Additionally, if you are experiencing the issue on Android, the system uses a different set of root CAs than Chrome does, so you may want to verify that your TLS certificate is (transitively) signed by a root CA installed on your system: https://tamingthedroid.com/trusted-credentials

ljtijhuis commented Apr 23, 2018

Hi guys, running into the same issue when using a localhost dev certificate. Any advise on how to make it accept it?

aprilmintacpineda commented May 1, 2018

I run on the same issue. Here’s what the situation looks like:

I found some articles on stackoverflow and a lot more from my duckduckgo search but I wasn’t able to find any answer.

  • I’m running my app via the expo app downloaded on my android phone. I’m not using any VMs to run my frontend and backend.
  • I have tried 10.0.2.2:3000. Same result.
  • I have tried my own IP. Same result.
  • I have tried to search the best places that I know of, but I couldn’t find any answers.

aprilmintacpineda commented May 1, 2018

I think it would be good to add these kind of info to the docs. «Making network requests to your localhost». Then add «Using an emulator.» and «Using your phone.».

aprilmintacpineda commented May 1, 2018

aprilmintacpineda commented May 1, 2018

I’m using the CLI, and I can’t see any instructions how to actually configure this thing.

aprilmintacpineda commented May 2, 2018 •

After going to sleep and upon waking up, I figured out what the answer was. I seem to have forgotten networking fundamentals.

Читайте также:  Опера для андроид кэш

What’s going on here?

I’m pretty new to expo and how it managed to push my app on my phone with wireless connection was a magic at first until I remembered networking. Basically expo pushes the app using the «lan» connection (in my case), your PC and the mobile you are using must be connected to the same network for this to work. Don’t get me wrong I don’t fully understand how expo works on the foundation level though I’d love to know the secret spell for its magic. (LOLS).

My computer is running the localhost server (nodejs) on localhost port 3000 ( localhost:3000 ), so I need to make a request to the computer’s port 3000 in order for this to work, unfortunately for me, I was getting my IP thru https://duckduckgo.com/?q=what%27s+my+ip%3F&atb=v113-7_y which didn’t work because I’m running on LAN so it needs to be the IP on the LAN network. So what you need is LANIP:3000/path/to/request for this network request to work.

Now that you know your IP address, instead of doing http://localhost:3000/a-request do http://TheIpGoesHere:3000/a-request , in this case, your phone will make a request to your PC’s port 3000 where the localhost is running. Example: http://192.168.1.2:3000/login .

If someone can explain this better or can add more information as to why the other works and why the other ones don’t, please mention me.

Источник

Network request failed android (emulator and device) #5469

Comments

ms4ever7 commented Aug 28, 2019

🐛 Bug Report

Environment

Expo CLI 3.0.10 environment info:
System:
OS: macOS 10.14.5
Shell: 5.3 — /bin/zsh
Binaries:
Node: 8.9.0 —

/.nvm/versions/node/v8.9.0/bin/node
Yarn: 1.12.3 — /usr/local/bin/yarn
npm: 5.5.1 —

/.nvm/versions/node/v8.9.0/bin/npm
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.3/10G8 — /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.0 => 32.0.6
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
react-navigation: 2.3.1 => 2.3.1
npmGlobalPackages:
expo-cli: 3.0.10

Android device and emulator

Steps to Reproduce

So I’m really new to expo and don’t know how all your magic works, and I’m having an error like this:

So I’m having this error on both emulator and device build — TypeError: Network request
I’ve found a lot of issues related to problem like this, but the solutions did not really help.

Here is how I’m making request:

and here is my app.json :

Also, I know that there is some issue like this — #1606
but did not find solution there.

The text was updated successfully, but these errors were encountered:

cruzach commented Aug 28, 2019

Are you making the request to localhost ? Is this working correctly on iOS (or have you not tried on iOS)? Also, is this a standalone app, or are you running it in the Expo Client app?

ms4ever7 commented Aug 28, 2019

did not try on iOS, they need it only on android
earlier I’ve worked with xCode

so request is making to api, not to localhost, as its caused on both localhost and device with apk build
its Expo @cruzach client app

cruzach commented Aug 28, 2019

I don’t think I understand. Could you explain what you mean by «as its caused on both localhost and device with apk build»?

ms4ever7 commented Aug 29, 2019 •

Sorry,
I mean that I was thinking that it may be only local error,
so I’ve tried to make apk build to check on real device — but error still exists @cruzach

cruzach commented Aug 29, 2019

Ah okay, understood. What happens if you try to visit your endpoint in the browser?

Also, please share a minimal repro for this. I suggest using any test API endpoint, rather than your own API (just to narrow down the possible root causes)

Chasty commented Oct 7, 2019

I’m having the same issue, any solution please.

Читайте также:  Экранная мышь для андроид

eyeamkd commented Oct 7, 2019

test API works fine, but local server doesn’t respond. getting the same error

rodriguezmanu commented Oct 7, 2019

onlyargon commented Oct 28, 2019

The same issue experiencing. Any fix ??

cruzach commented Oct 28, 2019

Still need a repro for this, so if you’re having the same issue, please share a minimal reproducible example

onlyargon commented Oct 28, 2019

This is how i try to read the API

onlyargon commented Oct 29, 2019

@cruzach Please find sample repo here

yatagan commented Oct 30, 2019

I have the same issue both on Android device and iOS Simulator, steps to reproduce: https://docs.expo.io/versions/latest/guides/using-clojurescript/

ThiagoLAMF commented Oct 31, 2019

yatagan commented Oct 31, 2019

onlyargon commented Nov 2, 2019

This is fixed for me when I deploy endpoint with https

cruzach commented Nov 4, 2019

@ms4ever7 can you confirm @onlyargon’s solution?

ms4ever7 commented Feb 25, 2020

Thx, @ThiagoLAMF , worked for me

nfabacus commented May 10, 2020

yes, I also have the same issue only for android simulator. web and ios simulator work fine. For the time being for android simulator, I am using ngrok to access localhost via https.

yemialpha commented Jul 1, 2020

please is there a solution to this problem yet?

obie3 commented Sep 16, 2020

Please I’m having similar issue, my app works well on iOS and postman but always throws a network error on android further debugging with adb and axios showed

< err:
< [Error: Network Error]
config:
< url: 'https://xxx.yyy.zzz:7071/',
method: ‘post’,
data: ‘<"id":"12345678910">‘,
headers: [Object],
transformRequest: [Object],
transformResponse: [Object],
timeout: 0,
adapter: [Function: xhrAdapter],
xsrfCookieName: ‘XSRF-TOKEN’,
xsrfHeaderName: ‘X-XSRF-TOKEN’,
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
body: ‘<"id":"12345678910">‘,
request:
< UNSENT: 0,
OPENED: 1,
HEADERS_RECEIVED: 2,
LOADING: 3,
DONE: 4,
readyState: 4,
status: 0,
timeout: 0,
withCredentials: true,
upload: <>,
_aborted: false,
_hasError: true,
_method: ‘POST’,
_response: ‘Unable to resolve host «xxx.yyy.zzz»: No address associated with hostname’,
_url: ‘https://xxx.yyy.zzz:7071/’,
_timedOut: false,
_trackingName: ‘unknown’,
_incrementalEvents: false,
responseHeaders: undefined,
_requestId: null,
_cachedResponse: undefined,
_headers: [Object],
_responseType: »,
_sent: true,
_lowerCaseResponseHeaders: <>,
_subscriptions: []
>,
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON],
line: 178238,
column: 26,
sourceURL: ‘http://192.168.0.16:19001/node_modules/expo/AppEntry.bund

here is a screenshot of my environment

xgenem commented Oct 22, 2020 •

I am currently facing the same issue. I’m surprised this wasn’t resolved. Hope someone from expo can help.

Fetch in iOS works, but in android it throws a Network request failed.

brentvatne commented Oct 22, 2020

please post a new issue with a mcve if you are experiencing some problem that you believe to be a bug in expo tools.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

TypeError: Network request failed when fetching a file:// uri #2402

Comments

0xori commented Oct 11, 2018

Environment

App target — Standalone & Client for testing

Steps to Reproduce

  1. use this expo example of recording audio
  2. mix it with this example of uploading to firebase

Expected Behavior

fetching a file URI from the device file system should return a valid response.

Actual Behavior

I’m getting a network error exception

TypeError: Network request failed

and if I’m running with remote JS debug mode I can see this error in chrome console

Failed to load file:///data/user/0/host.exp.exponent/cache/ExperienceData/…/Audio/recording-eee85da3-7121-4273-86a7-686098180662.m4a: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Some Code

The text was updated successfully, but these errors were encountered:

nebmesemaou commented Oct 11, 2018

you can use the FileSystem api to download remote file or read local file

0xori commented Oct 14, 2018

@nebmesemaou I’m trying to upload a local file to firebase. Tried to use the FileSystem API, I can read the file as a string and then try to upload it, the problem that it’s working on android but I’m getting an error for ios.

Unhandled promise rejection Error: File ‘file:///var/mobile/Containers/Data/Application/7B5B62F5-172E-4D97-884E-DA77052CD847/Documents/ExponentExperienceData/. /myDir/recording-8B438F16-7376-4509-94B7-7BB013F28327.m4a’ could not be read.

Cheonsoon commented Nov 6, 2018

@0xori file uri should be base64 encode then decode, if you are trying to transfer it through.. As some special char would be url encoded and the FileSystem.read function would use the wrong path.

Читайте также:  Huawei modem для android

moxorama commented Nov 7, 2018

Also got this issue.

base64 firebase upload also broken on android

DhirajKate commented Nov 13, 2018

I am also getting same issue

0xori commented Nov 13, 2018

It happened because I was running it on remote js debug mode, when I turned it off it works

sjchmiela commented Nov 22, 2018

Great news, @0xori! I’ll let myself close this issue then, thank you for updating the thread with your solution! 🙂

edzillion commented Nov 23, 2018

It happened because I was running it on remote js debug mode, when I turned it off it works

I am having this same problem and turning off remote debugging hasn’t fixed it.

I get this error:

I am trying to upload an image from the ImagePicker API, I note that others seem to be having this same issue (see comments) : https://stackoverflow.com/a/52953268/65025

romines commented Dec 2, 2018

I was able to work around the fetch Network error by downgrading to SDK version 28.

sjchmiela commented Dec 3, 2018

TL;DR: Replace fetch().blob() with:

Let me guide you through some code to understand the problem better:

Let’s start with fetch function. It’s currently not supported natively by JSC on which JS code runs. When we use React Native, it’s being polyfilled by the framework.

Pre-0.57, React Native used a regular whatwg-fetch polyfill, implementing fetch with XMLHttpRequest ( XMLHttpRequest polyfill has always been implemented by RN), to enable developers to use fetch (usage, dependency definition). ( whatwg-fetch has set xhr.responseType by default to «blob» .) React Native’s XMLHttpRequest implementation, in turn, uses NetworkingModule to issue the request. So, at the end, NetworkingModule.sendRequest is called.

Inspecting NetworkingModule.sendRequest method we can see that before any real network request is constructed, it first iterates over mUriHandlers . It’s a list of objects conforming to UriHandler interface, which is very simple, and as the documentation says:

Allows to implement a custom fetching process for specific URIs. It is the handler’s job to fetch the URI and return the JS body payload.

So if we would like to support some custom URI scheme, we would add our own UriHandler to NetworkingModule , nice! 👌

In a basic React Native application (on Android), there is only one such custom handler, created by BlobModule — link. As we can see from the implementation, it runs only for requests that both:

  1. aren’t http:// or https:// and
  2. expect blob as response type.

For such requests, this handler is capable of returning a valid blob as expected. So why doesn’t it work in RN 0.57+?

This commit, which first landed in React Native 0.57 switched the default xhr.responseType from blob to text . Thus, BlobModule ‘s UriHandler doesn’t kick in, and since okhttp doesn’t recognize URL of file:// scheme, it throws an exception.

It’s important to note that this commit doesn’t introduce a bug. In fact, it fixes a blob leak that was occurring due to fetch requests not releasing underlying native blobs when they’re done with it!

Since we really need this blob, and can’t use fetch (there’s no way to pass an option that would instruct fetch to start with responseType = blob ) we have to construct XMLHttpRequest ourselves.

The following snippet creates a very basic blob promise:

Источник

Оцените статью