Skip to content
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

Axios timeout when posting to API on remote server (Only on Android device) #28739

Closed
emad-ir opened this issue Apr 23, 2020 · 4 comments
Closed
Labels
Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. Newer Patch Available Platform: Android Android applications. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@emad-ir
Copy link

emad-ir commented Apr 23, 2020

Description

We have a backend that is connecting to a SOAP server and translating it to REST. The SOAP server can only be connected via VPN.

When running backend on local, API calls work fine both on Emulator and Android device.

But when we deployed the backend on a remote server, the Android device timeout (15 seconds) when trying to make a request.

Environment

npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.4 => 0.61.4 npmGlobalPackages: react-native-cli: 2.0.1

Expected Behavior

Axios resolves the post request without timing out.

Couple of suggested solutions online that I tried, and still got nothing working, were:

1. Create network_security_config.xml and link it on AndroidManifest.xml with android:networkSecurityConfig="@xml/network_security_config".

I also tried the solution below without the base-config, having just domain-config

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">remove_server_ip_address_here</domain>
    </domain-config>
</network-security-config>

2. Adding both android:usesCleartextTraffic="true" tools:targetApi="28"/tools:targetApi="29" to application tag in AndroidManifest.xml. Also tried just adding android:usesCleartextTraffic="true" without the tools:targetApi

3. Tried adding xmlns:tools="http://schemas.android.com/tools" android:targetSandboxVersion="1" to the root element of AndroidManifest.xml


Keep in mind I do have both <uses-permission android:name="android.permission.INTERNET" /> and <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> in my AndroidManifest.xml

Again the request only timeout when trying to post to remote server on an IP address, and it only doesnt work on Android device, everything works fine on Emulator.

Please help, Im not sure what to try anymore!

@react-native-bot react-native-bot added Platform: Android Android applications. Platform: iOS iOS applications. Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. and removed Needs: Triage 🔍 labels Apr 23, 2020
@github-actions
Copy link

⚠️ Missing Environment Information
ℹ️ Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.

@hramos hramos added Newer Patch Available Type: Question Issues that are actually questions and not bug reports. labels Apr 23, 2020
@hramos
Copy link
Contributor

hramos commented Apr 23, 2020

This seems like it might be more of a question around making network calls on Android, and not a specific issue with React Native.

@github-actions
Copy link

We are using GitHub issues exclusively to track bugs in React Native. GitHub may not be the ideal place to ask a question, but you can try asking over on Stack Overflow, or on Reactiflux.

@github-actions
Copy link

⚠️ Using Old Version
ℹ️ It looks like you are using an older version of React Native. Please upgrade to the latest version, and verify if the issue persists. If it does not, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the current release.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 1, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. Newer Patch Available Platform: Android Android applications. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

3 participants