skip to Main Content

I’m encountering an issue with my React Native mobile apps deployed on Samsung Galaxy Tab devices (2021+).

When making HTTP API requests to a private domain, I consistently receive a generic network error. However, if I make a request to a public domain before the private one, subsequent requests to the private domain succeed.

I believe I’ve ruled out DNS issues and TLS problems, and I’ve used various HTTP libraries such as axios/fetch.

My setup includes React Native 0.68.1+, Java SDK 21+, Gradle 7+, Android min SDK 31, Axios v0.27.2+, AndroidX, and disabled Google Play services with enabled Samsung Knox. NewArch is disabled on a few but enabled on others.

Request types include both JSON and x www form encoded types. Postman and browser tests always work fine. Pings etc also work fine to expected destinated although not tested on actual devices.

Any insights on why this sequencing workaround is needed and how to address the primary network error directly would be highly appreciated!

Using Axios to exclusively connect to my private domain on a private network via WiFi, I get this response:

"AxiosError: Network Error"

Using fetch in the same scenario, I get the following response:

"TypeError: network request failed"

Fetch response output:

{
    "UNSENT": 0,
    "OPENED": 1,
    "HEADERS_RECEIVED": 2,
    "LOADING": 3,
    "DONE": 4,
    "readyState": 1,
    "status": 0,
    "timeout": 0,
    "withCredentials": true,
    "upload": {},
    "_aborted": false,
    "_hasError": false,
    "_method": "POST",
    "_perfKey": "network_XMLHttpRequest_https://xxxxxxxxx",
    "_response": "",
    "_url": "https://xxxxxxxxx",
    "_timedOut": false,
    "_trackingName": "unknown",
    "_incrementalEvents": false,
    "_performanceLogger": {
        "_timespans": {
            "network_XMLHttpRequest_https://xxxxxxxxx": {
                "startTime": 1706111990285
            }
        },
        "_extras": {},
        "_points": {
            "initializeCore_start": 1706111989144,
            "initializeCore_end": 1706111989289
        },
        "_pointExtras": {},
        "_closed": false
    },
    "_requestId": 1,
    "_headers": {
        "content-type": "application/json"
    },
    "_responseType": "",
    "_sent": true,
    "_lowerCaseResponseHeaders": {},
    "_subscriptions": [
        {},
        {},
        {},
        {},
        {},
        {}
    ]
}

If I make a request to a non-private domain first, the above call succeeds.

I’ve also tried tcpdump/WireShark/tshark to investigate packets. I’ve also tried non-encrypted traffic to rule out TLS issues.

2

Answers


  1. Chosen as BEST ANSWER

    I switched from using axios/fetch and made the request using XmlHttpRequest (within a promise) and was able to get more information.

    java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
    

    I'm surprised I wasn't able to see this error using axios/fetch as I read somewhere that these libraries all use XmlHttpRequest under the hood.

    It turned out that I had a slightly misconfigured certificate that didn't include the CA bundle. The reason why a pre-flight request worked is because of my firewall.

    If anyone else is experiencing generic network issues I would encourage you to use XmlHttpRequest as this seems to output a lot more detail.


  2. It sounds like your React Native app on Samsung Galaxy Tab devices is experiencing a network issue where HTTP API requests to a private domain only succeed after making a request to a public domain. Given your detailed troubleshooting steps, this issue might be related to a specific configuration on the devices or a network caching/initialization problem.

    Consider these steps:

    Check Device Configuration: Verify any specific network settings or permissions on the Samsung devices that might affect private domain access.

    Network Initialization: It’s possible the first request to a public domain initializes certain network settings. Try explicitly initializing network configurations in your app before making private domain requests.

    Debug Logs: Look at detailed network logs or system logs from the device during the failure to identify any anomalies.

    Test on Different Network: Try a different network setup to rule out issues specific to your current network.
    This issue is quite unique and might require a process of elimination to diagnose the exact cause.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search