-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch throws 'Network request failed' on Android SDK Platform 24 #17891
Comments
https://snack.expo.io/rJYNZk0B- can repro the issue consistently for me with Android 24 sdk. if it is android 7.0 bug, why does native request work well on Android 7.0 for the same url. |
https://stackoverflow.com/questions/39133437/sslhandshakeexception-handshake-failed-on-android-n-7-0 adding ssl_ecdh_curve prime256v1; to your /etc/nginx/snippets.d/ssl_default it's android 7.0 bug( not react native) |
Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version? I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer. |
@mnshkv if it is android 7.0 bug, then why does native http request code work well? |
@paulus6lau i think problem in RCT-Network |
Same.. Latest RN version.. Axios and Fetch also not able to fetch https request but http yes.. Android |
same issue on 0.55.. please fix.. Orz |
+1 |
same issue too. Works fine on iOS |
I had added TRY ... CATCH ... within it, but it still cant handle the exception :( +1 |
We can catch error by this way (from docs):
Case you want to config (from docs):
|
@havinhthai What can i do next >< |
@sooxiaotong I solved this issue by replace url (ex: https://wifi.unifi.com.my) to IP of Server. example: If in local, you can replace http://localhost:3000 to http://23.45.42.23:3000 (23.45.42.23 is IP of your laptop) |
+1 |
i have a problem like this. |
This remains an issue with react-native 0.55.4, and is present on 0.55.3, 0.55.2, 0.55.1, and 0.55.0. It turns out that the react-apollo library also depends on this. |
Am using react-native 0.55.1, Android seems working fine on my end but I have this issue with iOS. I have played with AppTransportSecurity protocol as well. Any solutions other than downgrading RN version |
Having the same problem. Works fine on iOS |
Turns out the problem is the Android bug, and here is how to fix it: I think this should return an Exception when the version is Android 7 to verify that the security settings are correct. For reference, this is how the solution was found: https://stackoverflow.com/questions/45170365/react-native-fetch-throws-network-request-failed-on-android-7-but-works-fin#45278124 |
I'm having this issue. I also get some error about "Tunnels" that I can't log so I don't know anything else. This is https POSTing to an Azure web service. The certificate chain is just fine. Using the IP address is not an option obviously, as Azure will probably load balance requests. I also can't change how it handles certificates, that's entirely out of my control. |
Im experiencing same issue, im updating (rewriting) my app with newer version (RN 56). but funny thing is my old app works pretty fine with same request to same https server on same android 7 device and it was written by RN 42. i think there is something between android 7 and okhttp that cause this problem. |
I detached with Expo. That seemed to be a cause of the issue. To fix it, I had to run |
@KthProg I dont use expo and building my apps with native code but still experiencing same issue. |
I can't be totally sure what the cause is then. Mine was fixed once the bundle scripts were generated. There may have been an issue with the version of React Native/Expo I was using. I deleted everything I had and brought it all down from source control, then installed all the packages again and upgraded Expo to the latest. |
My issue was only in production by the way, so it may have been a different issue related to Expo. |
it seems like it has something to do with gzip. If I add the header
|
Since the issue is "closed" they will probably not get notified about our comments anyways. I would try to find a more recent similar issue, create a new issue and mention this one, or mention one of the developers names here. @mnshkv (hopefully that works?) |
If it is working with Ios then replace localhost to main ip address of Your computer. |
@paulus6lau same issue in android. any solution? |
@adirzoari use network ip address where you are using localhost for sending request. |
@balwinder4264 it happen my in production version (not with localhost address).. I send to real address and it happen when no internet connection |
@adirzoari if there is no internet connection use 127.0.0.1 instead localhost. If you maintain server in your machin. Or if you are sending request outside obviously you should have internet connection. |
@balwinder4264 umm but if suddenly there is no internet connection, I can't replace it to 127.0.0.1.. I work with specific url to get data, but if no internet it shows me 'Network request failed' |
@adirzoari because you can’t access intrnet URL without internet.!! As u can not send message on whatsapp without internet |
@balwinder4264 I know I agree with it, but how I catch this error and show to the users specific error in this case? |
@adirzoari put your request in try catch and make alert in catch block alert(“network error”) |
The problem for me was that React Native brought back the type 'image' for images from the picker. The type passed to the file uploader needed to be like 'image/jpg'
|
-The most suggested answer even on stackoverflow, I tried this solution many times, but the issue still persist. |
I cannot understand whats the point of error message "Network request failed" ... what happened the cold weather caught it or the aliens from the future took it... a bit more detail would be appropriate @nickjuntilla answer was close to my use case but it didn't work either. ` const { name, date, description, location, uri, mime, time } = this.state;
` |
Is this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v: react-native-cli: 2.0.1 react-native: 0.46.3
node -v: v7.7.3
npm -v: 4.1.2
yarn --version (if you use Yarn): ---
Then, specify:
Target Platform: Android
Development Operating System: macOS Sierra 10.12.5 (16F73)
Build tools: Android Studio
Steps to Reproduce
fetch('https://pricesea.ru/api/auth/info', {
credentials: 'include'
}).then(res => {
...
}).catch((e) => {
console.log(e);
});
Expected Behavior
Request should return HTTP code 200 and some data or HTTP code 401.
Actual Behavior
I have an error:
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (fetch.js:441)
at XMLHttpRequest.dispatchEvent (event-target.js:172)
at XMLHttpRequest.setReadyState (XMLHttpRequest.js:546)
at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:381)
at XMLHttpRequest.js:485
at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
at MessageQueue.__callFunction (MessageQueue.js:260)
at MessageQueue.js:101
at MessageQueue.__guard (MessageQueue.js:228)
at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:100)
Reproducible Demo
the bug(#15100) is reported by @DmitryMaksakov but closed with not-finding root cause.
(Paste the link to an example project and exact instructions to reproduce the issue.)
I have tested different API SDK Platform versions (from 22 up to 26), the problem reproduces only on API SDK Platform 24 (Android 7.0).
I also did this request via native Android app and it was successful on all Platform versions, even 24.
The text was updated successfully, but these errors were encountered: