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

Getting NETWORK_ERROR sometimes when requesting #181

Open
amabdul opened this issue Sep 4, 2018 · 29 comments
Open

Getting NETWORK_ERROR sometimes when requesting #181

amabdul opened this issue Sep 4, 2018 · 29 comments
Labels

Comments

@amabdul
Copy link

amabdul commented Sep 4, 2018

When I try to fetch data sometimes I am getting the error, most of the time works fine.
If it generate error once, the chance of occurence is high, in the immediate call.

The error log in the chrome debugger is:

{duration: 126, problem: "NETWORK_ERROR", originalError: Error: Network Error
at createError (blob:http://10.0.0.59:8081/f5cf0951-79a8-4e8c-9a37-0013ae13…, ok: false, status: null, …}

react-native-cli: 2.0.1
react-native: 0.55.4

I am not getting why the error occur for the same success request. The network is reachable. Since it occur sometime its become a headache. Please help

@skellock
Copy link
Contributor

skellock commented Sep 4, 2018

Trying console.logging that response.originalError... that should shed some light on things. That's the underlying axios error. the status: null would mean that that server was not reached (whether that's a network issue or a server not responding, we can't really know).

@amabdul
Copy link
Author

amabdul commented Sep 6, 2018

Can I implement retry logic for the same request, if I got the specific error. Would something like this work with apisauce: axios/axios#934.

@skellock
Copy link
Contributor

skellock commented Sep 6, 2018

You can access the axiosInstance after creating an api by doing api.axiosInstance. That way you have full access to everything they can do.

@amabdul
Copy link
Author

amabdul commented Sep 6, 2018

hi I wrote like this

api.axiosInstance.interceptors.response.use(function (response) {
if (response.data) { // for NETWORK_ERROR data will be null
console.log('interceptors response success', response)
} else {
console.log('interceptors response error', response)
return api.axiosInstance.request(response.config);
}
return response;
}, function (error) {
return Promise.reject(error);
})

I always get log 'interceptors response success' for fine calls. But nothing got logged for NETWORK_ERROR. Means not intercepted for this error. Why is that?

@skellock
Copy link
Contributor

skellock commented Sep 6, 2018

I believe axios treats that as an exception, so perhaps doesn't take the interception route home? I haven't tried that before so I can't say for sure.

@amabdul
Copy link
Author

amabdul commented Sep 8, 2018

how we can effectively debug the issue. to find who is responsible for the error
is it the apisause OR actually the server
do apisause has the issue "for some request whether it end up in NETWORK_ERROR"

@skellock
Copy link
Contributor

skellock commented Sep 8, 2018

NETWORK_ERROR is set from apisauce. It makes that decision by investigating the response value from the axios exception. That's the originalError property that comes back when you make that call.

Everything that apisauce knows comes from that, so if you have a look at that error message and stack trace closely, that might give you some more info.

In your original post, I see something like blob in there. That's the new blob support that's in React Native 53 or 54 (I can't remember), so that's throwing a little bit of obfuscation into the mix as well.

Getting access to the server logs can help too (not sure if that's an option for you or not).

Lack of a good error message certain is frustrating to track down.

@keerthi0611
Copy link

When I try to fetch data sometimes I am getting the error, most of the time works fine.
If it generate error once, the chance of occurence is high, in the immediate call.

The error log in the chrome debugger is:

{duration: 126, problem: "NETWORK_ERROR", originalError: Error: Network Error
at createError (blob:http://10.0.0.59:8081/f5cf0951-79a8-4e8c-9a37-0013ae13…, ok: false, status: null, …}

react-native-cli: 2.0.1
react-native: 0.55.4

I am not getting why the error occur for the same success request. The network is reachable. Since it occur sometime its become a headache. Please help

Even i am facing the same issue...........

@keerthi0611
Copy link

Can someone please post the solution if u get any info about this?

@cassiossantos
Copy link

cassiossantos commented Jul 30, 2019

Check your network connection... I had the same problem hahaha

@waleedarshad
Copy link

I am having same issue @keerthi0611 are you able to solve it?

@cassiossantos
Copy link

@waleedarshad Check your network connection . Maybe your device is disconnected.

@fuavix
Copy link

fuavix commented Nov 18, 2019

My network is good, but I still get
"problem":"NETWORK_ERROR"
"status": null

@ivandomar
Copy link

Guys, sadly I'm here for the same reason. NETWORK_ERROR pops out without any clue. I've noticed that it depends on the machine whom listens the requests. But couldn't realize any possible cause.

@dekameron22
Copy link

+1

1 similar comment
@YashYash
Copy link

YashYash commented Jun 6, 2020

+1

@PecoCaballero
Copy link

  • 1

@mabecth
Copy link

mabecth commented Jun 22, 2020

I get the NETWORK_ERROR in react-native v0.61.5 on iOS if I minimize the app during the request before a response is received. The request however still reaches the server but axios reports an NETWORK_ERROR with status: null. Any ideas why this happens and how to solve it?

@HassanRazaMuhammadTufail

I have same issue NETWORK_ERROR with status: null

@RaviTeja-94
Copy link

I facing the same NETWORK_ERROR problem ,

"originalError": [Error: Network Error],
 "problem": "NETWORK_ERROR",
 "status": null,

@goltaraguilherme
Copy link

I had same issue NETWORK_ERROR status: null.
So, You should try:
ipconfig in powershell and get the ipv4.
You have to change localhost:port to your ipv4:port

@augini
Copy link

augini commented Aug 27, 2020

THE SOLUTION is:
on Android you need to specify the file path with file:// as prefix. So do like this:

      const audio = {
        uri: 'file://' + this.recorder.fsPath,
        type: 'video/mp4',
        name: filename
      }

Good Luck

@Marianbc
Copy link

Marianbc commented Apr 8, 2021

Had this issue. I was following a tutorial that was using an emulator, but I was using a real device for my testing.
ipconfig to get your IPv4 for your apisauce client baseURL.
such as: baseURL: "http://199.199.9.90:8000/api",
setup your django API not on localhost (as this can't be accessed from a real device).
python manage.py runserver 0.0.0.0:8000
good luck!

@absmugz
Copy link
Collaborator

absmugz commented May 24, 2021

@amabdul did you come right ? so we can close this ?

@farzan106
Copy link

I have the same issue, even in my baseURL I have used my machine ipv4 address instead of localhost but still the problem remains

@Fraser123456
Copy link

So I had a similar issue and it was because I was sending the date to my APS .net backend but the date wasn't in a string format.
When I converted my date to a string then the request went through.

@anicetfosso
Copy link

Check the data, I had the same problem and noticed that a variable in my data was undefined

@TarSandorr
Copy link

Well, I tried all of the possibilities, I used the correct IPv4, IPv6, './listings/, localhost.
I also downloaded the zipped files and tried them, every time I got “problem”: “NETWORK_ERROR”.
Is there somebody who resolved the problem?

The response of the request:
Object {
“config”: Object {
“adapter”: [Function xhrAdapter],
“baseURL”: “http://192.168.0.10:9000/api”,
“data”: undefined,
“headers”: Object {
“Accept”: “application/json”,
},
“maxContentLength”: -1,
“method”: “get”,
“params”: Object {},
“timeout”: 0,
“transformRequest”: Array [
[Function transformRequest],
],
“transformResponse”: Array [
[Function transformResponse],
],
“url”: “/listings”,
“validateStatus”: [Function validateStatus],
“xsrfCookieName”: “XSRF-TOKEN”,
“xsrfHeaderName”: “X-XSRF-TOKEN”,
},
“data”: null,
“duration”: 69619,
“headers”: null,
“ok”: false,
“originalError”: [Error: Network Error],
“problem”: “NETWORK_ERROR”,
“status”: null,
}

@uxinnuendo
Copy link

So I had a similar issue and it was because I was sending the date to my APS .net backend but the date wasn't in a string format. When I converted my date to a string then the request went through.

Same here, apisauce doesnt even send the request at all, just returns NETWORK_ERROR because the payload is malformed - needs better handling.

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

No branches or pull requests