React-Native Network request failed on Android Emulator API 16-19 with specific SSL Cipher suite
See original GitHub issue🐛 Bug Report
To Reproduce
This bug is related to React-Native v0.59.1
react-native init testnet
- Copy these lines to your App.js above
render()
componentDidMount() {
this.testNet();
}
testNet(){
console.log("Executing test function");
fetch('https://reqres.in/api/users?page=2').then(response => response.json()).then(json => console.log("TESTOUTPUT",json['total']))
}
Try to run project on Android Emulator running on API 16-19 with Google APIs, You will have this error:
03-18 15:00:36.022 2191-2224/com.testnet W/ReactNativeJS: Possible Unhandled Promise Rejection (id: 0):
TypeError: Network request failed
onerror@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:24080:31
dispatchEvent@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:28724:31
setReadyState@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:28477:33
__didCompleteResponse@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:28304:29
emit@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:3280:42
__callFunction@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2577:49
http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2334:31
__guard@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2531:15
callFunctionReturnFlushedQueue@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2333:21
callFunctionReturnFlushedQueue@[native code]
Notes:
- This testing demo is using an HTTPS website, So it’s not related to network security config cleartext issue.
- The problem occurs with specific SSL/TLS Cipher suites for web-servers which are the following as example:
Cipher suites enabled for https://reqres.in and all other Cloudflare Free plan SSL sites:
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA (0xC009)
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (0xC00A)
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 (0xC023)
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 (0xC024)
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xC02B)
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (0xC02C)
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (0xCC14)
It seems the whole project cannot access internet connectivity, I have the permission in the manifest to access internet
<uses-permission android:name="android.permission.INTERNET" />
Otherwise you can test the same project on Android Emulator running on API 20 or later.
Expected Behavior
Expected console log output with 'TESTOUTPUT', 12
.
Code Example
https://snack.expo.io/@areeb111/testnet
Environment
$ react-native info
info
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Memory: 393.43 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 9.11.1 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.3, 24.0.0, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.1, 27.0.3, 28.0.3
System Images: android-16 | Google APIs Intel x86 Atom, android-17 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-23 | Android TV Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.1 => 0.59.1
npmGlobalPackages:
react-native-animatable: 1.2.4
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
react-native-modal: 5.4.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:33 (2 by maintainers)
Top Results From Across the Web
React Native Post Request via Fetch throws Network Request ...
At the moment I developing an Android App with React Native therefore I'm planning to use fetch for doing a post request for...
Read more >Improve "TypeError: Network request failed" error message
I get error messages when I make a request with fetch api on android (btw the same code is working perfectly fine on...
Read more >Network request Failed. Linux with Android-Studio, ExpoGo ...
I'm running pop_os(Linux) and using expoGo with Metro bundler and Android-Studio emulator...I keep getting. Network request failed at ...
Read more >Debugging: the process of elimination, workarounds and more
I describe how I debugged the error 'TypeError: Network request failed' when trying to connect to a local server from an Android or...
Read more >Expo React Native network request failed - YouTube
This video shows how to solve react native expo network request failed. if the this video helped leave a like and subscribe to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok. Ive found a workaround:
Same problem here after upgrading from 0.57 to ReactNative 0.59.1.
TypeError: Network request failed at XMLHttpRequest.xhr.onerror (47baf4cc-4977-4d41-b6f0-f842f48c5840:23673) at XMLHttpRequest.dispatchEvent (47baf4cc-4977-4d41-b6f0-f842f48c5840:28317) at XMLHttpRequest.setReadyState (47baf4cc-4977-4d41-b6f0-f842f48c5840:28070) at XMLHttpRequest.__didCompleteResponse (47baf4cc-4977-4d41-b6f0-f842f48c5840:27897) at 47baf4cc-4977-4d41-b6f0-f842f48c5840:28007 at RCTDeviceEventEmitter.emit (47baf4cc-4977-4d41-b6f0-f842f48c5840:3290) at MessageQueue.__callFunction (47baf4cc-4977-4d41-b6f0-f842f48c5840:2587) at 47baf4cc-4977-4d41-b6f0-f842f48c5840:2344 at MessageQueue.__guard (47baf4cc-4977-4d41-b6f0-f842f48c5840:2541) at MessageQueue.callFunctionReturnFlushedQueue (47baf4cc-4977-4d41-b6f0-f842f48c5840:2343)
ENV INFO: React Native Environment Info: System: OS: Linux 4.15 Ubuntu 16.04.5 LTS (Xenial Xerus) CPU: (4) x64 Intel® Core™ i5-5200U CPU @ 2.20GHz Memory: 183.18 MB / 7.66 GB Shell: 4.3.48 - /bin/bash Binaries: Node: 8.12.0 - /usr/local/bin/node Yarn: 1.9.4 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman npmPackages: react: ^16.8.4 => 16.8.4 react-native: ^0.59.1 => 0.59.1 npmGlobalPackages: create-react-native-app: 2.0.2 react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7