502 Bad Gateway error in angularjs app with asp.net web api

mikha
mikha used Ask the Experts™
on
I have an angularjs app, that makes calls to asp.net web api.
I am new to both, but inherited the project from someone else

once logged into angular app, after some time, I get "502 Bad Gateway" error, when i try to refresh the page.
I'm guessing may be there is a session timeout duration set somewhere, where the sessions times out and I'm logged out and when I try to do something on the site, it gives me 502 Bad Gateway error.

I am trying to find out how can I catch this exception where possible so that I can let users know that they need to log back in or some useful warning.

the angularjs app had a backend web api service that it talks. where would this happen , in the api or in the anuglar front end code?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Commented:
502 is the error message that a web server (nginx, apache, lighttpd, iis) would give when it tries to pass on the request to another internal service (php, cgi, reverse proxy, ...) and that operation fails.

So the backend get a request that cannot be handled. Try the server logs to find which call fails.

Author

Commented:
@noci - thanks for your comment.

I am checking the logs in the IIS, to see if I can find something.

I am not too familiar with angularjs yet.

so the basic set up is,

user types the product url out of few that we offer,

there is authentication layer/servie, which logs in clients and redirects them to product or site they want to go to.
once authenticated to one product, they don't have to log in to other products, sort of single sign on implementation

for the site, I'm working on

there is an angularjs frontend and asp.net REST based web api backend.

once  user log in cookies are set, based on which web api knows the user is authenticated.

I noticed in the web config of the web api, there is something like this

...
<appSettings>.....</appSettings>

<system.web>
   <authentication mode="Forms">
        <forms name=".hello" cookieless="useCookies"   domain=".mywebsite.com" timeout="20" ....
   </authentication>

</system.web>

could it be that this webapi times out and when angular code tries to make the call, it gets that 502 error.
may be the time out between the angularjs app and web api are not in sync. I am looking to figure out where one can set such a thing in angular js code.

i don't know if i can catch this 502 error in angularjs app and redirect to the login url on the authentication layer.
Software Engineer
Distinguished Expert 2018
Commented:
502 is a problem on the webserver, where the webserver needs to access a process behind it.
The API will see a failing request. withstatus 502 in stead of 200.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial