Network request failure in Android standalone app
See original GitHub issueSummary
Expo fails to connect to a sever and make a request in a built APK, but connects just fine in the Expo server. Please see the error in the attached screenshot. (I hope you don’t mind all the manipulated areas; I have to do that to maintain company secrets.) Code included at the bottom.
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
41.0.1
Environment
Expo CLI 4.3.2 environment info: System: OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster) Shell: 5.0.3 - /bin/bash Binaries: Node: 14.17.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/user-local/bin/yarn npm: 6.14.13 - /usr/local/bin/npm Watchman: 20210328.072220.0 - /opt/watchman/bin/watchman SDKs: Android SDK: API Levels: 19, 21, 23, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3 System Images: android-30 | Google APIs Intel x86 Atom IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 npmPackages: expo: ~41.0.1 => 41.0.1 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 react-native-web: ~0.13.12 => 0.13.18 npmGlobalPackages: expo-cli: 4.3.5 Expo Workflow: managed
Reproducible demo or steps to reproduce from a blank project
The error occurs somewhere within this try block because the “Failed to make request to…” error is printed:
try {
let reqsHeaders;
let fetchOptions = {
method: httpMethod,
headers: reqsHeaders,
body: (requestBody === null) ? undefined : requestBody,
}
if (requestType === RequestType.GET_TERMS_OF_SERVICE) {
fetchOptions.reactNative = { textStreaming: true };
}
let response = await LangUtils.timeout(
RestConstants.HTTP_REQUEST_TIMEOUT_MS,
fetch(uri, fetchOptions),
);
if (response.ok) {
// Handling OK response
} else {
Logger.warn(LOG_TAG, logText);
}
} catch (error) {
Logger.error(LOG_TAG, 'Failed to make request to ' + uri + ': ' + error.message);
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
hi there! please provide a reproducible example for us. we are not able to help without one.
https://stackoverflow.com/help/minimal-reproducible-example
Yes, you’re right, it was because of project code. After hours of debugging, I found the problem was not using “https” and instead using “http”. I know Expo is in continuous development, but maybe this could still be an issue. As in, the error message could be updated. It’s up to you. Also, this also threw an error in React Native, but there was no error message for this.