Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nativescript: HTTP failure response for unknown URL

I have a situation, I have pulled the latest changes from my branch and trying to run the application using tns run android command. The app is launched successfully but the API call is restricted throwing an error as soon as the app starts.

I have also gone through this answer but that's not the problem it seems. Because for other team members it is working fine. :/

    err {
JS:   "headers": {
JS:     "normalizedNames": {},
JS:     "lazyUpdate": null,
JS:     "headers": {}
JS:   },
JS:   "status": 0,
JS:   "statusText": "Unknown Error",
JS:   "url": null,
JS:   "ok": false,
JS:   "name": "HttpErrorResponse",
JS:   "message": "Http failure response for (unknown url): 0 Unknown Error",
JS:   "error": {
JS:     "originalStack": "Error: java.io.IOException: Cleartext HTTP traffic to elk.chennai-volunteer-294695.staging.c66.me not permitted\n    at new ZoneAwareError (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/
tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:1298:33)\n    at onRequestComplete (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:
45:34)\n    at Object.onComplete (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:37:13)",
JS:     "zoneAwareStack": "Error: java.io.IOException: Cleartext HTTP traffic to elk.chennai-volunteer-294...
like image 413
Yashwardhan Pauranik Avatar asked Jan 03 '19 07:01

Yashwardhan Pauranik


People also ask

How do you fix HTTP failure response?

The error you are facing is a timeout error. In order to fix this issue, there is a need to update the [User session timeout] system setting and to make sure to remove the Caching option, allow to modify it by internal users, and increase the Default value to 420.

What is HTTP failure response?

HttpErrorResponselink A response that represents an error or failure, either from a non-successful HTTP status, an error while executing the request, or some other failure which occurred during the parsing of the response.


2 Answers

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

Update your manifest file with the android:usesCleartextTraffic flag.

<application ... android:usesCleartextTraffic="true" ...>
like image 162
Manoj Avatar answered Oct 14 '22 19:10

Manoj


Go to: your-project\App_Resources\Android\src\main\AndroidManifest.xml

Update your manifest by adding android:usesCleartextTraffic="true" to existing rules in <application></application> tag, like as seen bellow

<application
    ...
    ...
    android:usesCleartextTraffic="true"
    ...
    ...
</application>
like image 42
Harrison O Avatar answered Oct 14 '22 17:10

Harrison O