apisauce icon indicating copy to clipboard operation
apisauce copied to clipboard

Getting NETWORK_ERROR sometimes when requesting

Open amabdul opened this issue 7 years ago • 29 comments
trafficstars

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

amabdul avatar Sep 04 '18 14:09 amabdul

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).

skellock avatar Sep 04 '18 14:09 skellock

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.

amabdul avatar Sep 06 '18 08:09 amabdul

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

skellock avatar Sep 06 '18 12:09 skellock

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?

amabdul avatar Sep 06 '18 12:09 amabdul

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.

skellock avatar Sep 06 '18 23:09 skellock

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"

amabdul avatar Sep 08 '18 12:09 amabdul

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.

skellock avatar Sep 08 '18 12:09 skellock

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 avatar Jun 24 '19 08:06 keerthi0611

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

keerthi0611 avatar Jun 24 '19 08:06 keerthi0611

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

cassiossantos avatar Jul 30 '19 21:07 cassiossantos

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

waleedarshad avatar Sep 16 '19 07:09 waleedarshad

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

cassiossantos avatar Sep 16 '19 13:09 cassiossantos

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

fuavix avatar Nov 18 '19 07:11 fuavix

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.

ivandomar avatar Jan 08 '20 17:01 ivandomar

+1

dekameron22 avatar May 25 '20 10:05 dekameron22

+1

YashYash avatar Jun 06 '20 04:06 YashYash

  • 1

PecoCaballero avatar Jun 19 '20 21:06 PecoCaballero

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?

mabecth avatar Jun 22 '20 13:06 mabecth

I have same issue NETWORK_ERROR with status: null

I facing the same NETWORK_ERROR problem ,

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

RaviTeja-94 avatar Jul 07 '20 11:07 RaviTeja-94

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

goltaraguilherme avatar Jul 17 '20 03:07 goltaraguilherme

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

augini avatar Aug 27 '20 02:08 augini

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!

Marianbc avatar Apr 08 '21 23:04 Marianbc

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

absmugz avatar May 24 '21 18:05 absmugz

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

farzan106 avatar May 31 '21 16:05 farzan106

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.

Fraser123456 avatar Jul 29 '21 18:07 Fraser123456

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

anicetfosso avatar Jan 03 '23 09:01 anicetfosso

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, }

TarSandorr avatar Feb 21 '23 10:02 TarSandorr

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.

uxinnuendo avatar Nov 12 '23 09:11 uxinnuendo