question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Network request failure in Android standalone app

See original GitHub issue

Summary

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.

Screenshot from 2021-05-28 22-11-33

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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
brentvatnecommented, May 29, 2021

hi there! please provide a reproducible example for us. we are not able to help without one.

https://stackoverflow.com/help/minimal-reproducible-example

0reactions
adrianbartyczakcommented, Jun 2, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Network request failed android (emulator and device) #5469
Network request failed android (emulator and device) #5469 ... is this a standalone app, or are you running it in the Expo Client...
Read more >
YouTrack APP on android "Network request failed"
In the iOS environment, I enter the address of my server, I log in and it is. If I enter the same address...
Read more >
React Native / Expo : Fetch throws “Network request failed”
but when i'm starting the app on Expo he throw me "Network request failed". Frontend fetch : submitForm = () => { var...
Read more >
NetworkException | Android Developers
Constructs an exception that is caused by a network error. Parameters. message, explanation of failure. cause, the cause (which is saved ...
Read more >
Mobile App monitoring FAQ - IBM
What happens for users with bad internet or network connections? What happens if reporting fails? Is data collected while offline? Is it possible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found