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

Network Error in React Native #6302

Open
nkqdev opened this issue Mar 15, 2024 · 8 comments
Open

Network Error in React Native #6302

nkqdev opened this issue Mar 15, 2024 · 8 comments

Comments

@nkqdev
Copy link

nkqdev commented Mar 15, 2024

Describe the bug

When i'm POSTa request then in the processing i'm switch to another app (before i'm receive response from server) then when i'm come back it say Network Error is anyone have the same issue and know the way to deal with this problem?

To Reproduce

No response

Code snippet

No response

Expected behavior

No response

Axios Version

^1.6.2

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

iOS 16.4

Additional Library Versions

RN 0.71.8
React 18.2.0

Additional context/Screenshots

No response

@kurucaner
Copy link

I'm getting the same error, but only from Android. I don't think this is related to Axios because I used the bare JavaScript fetch method and the API call just never resolves.

@nkqdev
Copy link
Author

nkqdev commented Mar 16, 2024

I'm getting the same error, but only from Android. I don't think this is related to Axios because I used the bare JavaScript fetch method and the API call just never resolves.

I'm stuck at this problem for like 1 week. Some people say that axios isn't using an API that called NSURLSession provide by Apple to make a request so when user switch to another app the OS just cancel that request.

@kurucaner
Copy link

I'm getting the same error, but only from Android. I don't think this is related to Axios because I used the bare JavaScript fetch method and the API call just never resolves.

I'm stuck at this problem for like 1 week. Some people say that axios isn't using an API that called NSURLSession provide by Apple to make a request so when user switch to another app the OS just cancel that request.

Honestly, in my case, I'm convinced that this is a backend problem. I created a basic Node.js backend and made a similar API call to it; everything was working just fine. We are looking into the issue and will keep you updated if we figure this out.

@suhaotian
Copy link

@nkqdev If it's GET data, if fetch data error, it should have chance to retry few times. check this article 3 Tips to Make Your App More Stable

@kurucaner And the android error, I think it's because you use '127.0.0.1' or 'localhost', I met this error before, and change the local IP to LAN ip(for example, like 192.168.1.10), then it's worked.

I use expo and this is how I get LAN ip in dev mode:

import Constants from 'expo-constants';

const host = Constants.expoGoConfig?.debuggerHost?.split(':')?.[0];
const API_URL = process.env.EXPO_PUBLIC_API_URL || '';

export const baseURL =
  host &&
  (host.startsWith('192.168') || host.startsWith('10.') || host.startsWith('172.')) &&
  (API_URL.indexOf('localhost') > -1 || API_URL.indexOf('127.0.0.1') > -1)
    ? 'http://' + host + ':' + (API_URL.split(':').pop() || '')
    : API_URL;

@nkqdev
Copy link
Author

nkqdev commented Mar 25, 2024

@suhaotian I'm using SOAP service so when it's say Network Error everything just stop and i don't see any retry

@vivek0046
Copy link

same issue ,any resolution?

@MenamAfzal
Copy link

Em facing the same issue ....!

1 similar comment
@wilsonmjunior
Copy link

Em facing the same issue ....!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants