Http status 0 only sometimes


#1

Hi all,
I’ve been struggling with an issue for the last day or two with no luck. I have a certain call within my app that is returning status code 0 sometimes. It’s happening frequently enough that it’s impacting usability. It works 100% of the time in chrome (and postman), I’m only seeing this problem on device. Furthermore, all other requests within my app seem to work just fine. I have one request in particular that fails about 20% of the time I call it with the infamous http status 0. I have cordova-plugin-whitelist installed, and the following lines in my config.xml:
<access origin="*"/> <access origin="cdvfile://*" /> <allow-navigation href="*"/> <allow-intent href="*"/>

From my understanding this should allow all requests through, and that seems to be working with most of my other calls. The fact that it only fails with this one particular call seems to point towards some sort of race condition, but I’ve re-written the code multiple times in different ways and I’m getting this error no matter what I do. I don’t think this is a network connectivity issue, because all my other calls are working.

I’m using angular v1.5.0, ionic bundle v1.2.4, ngCordova v0.1.24-alpha, angular-resource v1.5.0.

Here’s some example output of the error:
http error {"data":null,"status":0,"config":{"method":"PUT","transformRequest":[null],"transformResponse":[null],"data":[{"field":"user_master_id","condition":"=","value":97},{"field":"blob_type","condition":"=","value":"profile_img_primary"}],"url":"https://<my-domain>/blob","params":{"metadata":true},"headers":{"Accept":"application/json, text/plain, */*","x-latitude":<redacted>,"x-longitude":<redacted>,"x-token":"<redacted>","Content-Type":"application/json;charset=utf-8"}},"statusText":""}

Any advice here? I’m starting to run out of ideas.
Thanks!


#2

I have the same error on IOS device and use the same settings in config.xml. But for me HTTP url call is working to the server, but using HTTPS url is giving me this status 0 error.


#3

I encountered this before but in my case I’m getting http status 0 because the internet connection was intermittent.


#4

So it’s going to sound crazy, but we found a work-around to this issue. If anyone knows why this might happen I would love to understand this better.

So our backend uses a PUT search for to submit searches using json array as the request body. When we pulled this out, and started specifying the query in the query string of a GET instead, the problem goes away. We use PUT to update objects elsewhere, but it’s not causing problems. Can’t tell what the difference is. So maybe this is more of an angular problem? Very curious, but at least it works for now. Hope that helps someone.