Http failure response for https://www.test.in/v1/messages/: 0 Unknown Error", getting in angular http request occasionally
Asked Answered
P

0

0

i have implemented a global error tracking function in my angular application., there i gets this error occasionally ( whenever a user faces an error that error report will send to my db ) but most of the time my users facing below error ( atleast 10-20 times per day )

{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"https://www.test.in/v1/messages/","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://www.test.in/v1/messages/: 0 Unknown Error","error":{"isTrusted":true}}

both my frontend and backend has deployed in same server

firstly i assumed that it is due to network issue?but if it is due to network issue my error tracking api also must face same problem, but it didn't happen.

how to figure out cause of this issue?

my code

       this._messageService.getMessage(body).subscribe(
          (res: any) => {},
          (err: any) => {
            this._commonService.saveErrors({
              error: err,
              screen: this.pageName,
              funcName: "load-messages",
            });
          }
        );
Pitchford answered 19/1, 2023 at 9:18 Comment(4)
did you have a look at the logs on the backend?Hygienist
per documentation this is mostly a CORS issue, maybe your CORS configuration is good for correct responses, but it fails when you get an error response. Have a look here -> #47181134Hygienist
@DžanOperta firstly thankyou for your help, yes i have checked logs on backend . this error happens occasionally only,it is already in production mode ( some users getting these error on some apis) definitely it's not cors error now i suspect is it due to some timeout or due to power saving mode of mobile devices it itself turns off it's data connnectionPitchford
Are you running the requests when the app is in the background? As you said the second suspect could be one of the causes, implementing additional logging and monitoring of the app would help a lot by using some of the shelf solutions, or you can manually try to pass additional data to your payload of saveError function (as the current route, app state, device info, etc)Hygienist

© 2022 - 2024 — McMap. All rights reserved.