Azure app service node.js deployment - handling failover - node.js

I have deployed a node application in azure running under an app service. Now issue is that the sites goes down occasionally and stops responding. Once I restart the site its starts working.
If I see logs, its says IISNode has encountered an error.
My question is is there any way to log the error and restart node process gracefully.
What is the best practice approach for node website deployed in app service?
This is the only error I get-

According the list on https://azure.microsoft.com/en-us/documentation/articles/app-service-web-nodejs-best-practices-and-troubleshoot-guide/
500 1004-1018 There was some error while sending the request or processing the response to/from node.exe. Check if node.exe crashed. check d:\home\LogFiles\logging-errors.txt for stack trace.
And more best practices and troubleshooting scenarios, you can refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-web-nodejs-best-practices-and-troubleshoot-guide/.

Related

Nodejs API on Azure Web App Linux getting System.Threading.Tasks.TaskCanceledException exception

I have a node/express api that is has started to handle a bunch of concurrent traffic. I have an azure function job that is running that loops thru users and calls the api to run some further tasks. The app starts up properly and then starts handling the requests. This occurs when over 100 requests hit the server at the same time.
I am running PM2 but I see there error intermittingly. Any suggestions?
2022-02-24T06:10:11.626050103Z Failed to forward request to application. Encountered a System.Threading.Tasks.TaskCanceledException exception after 299999.177ms with message: The operation was canceled.. Check application logs to verify the application is properly handling HTTP traffic.

Unable to run the angular application. Getting error No such file exists robots933456.txt

I am running the angular application in Microsoft Teams and deploying it on Azure.
But it's not running up as it is looking for the robots933456.txt route.
It wasn’t the case before today.
Please guide me on how to proceed further.
On running the app the logs shows:
The error was natively on my side nothing to do with the above but pretty much seen and raised by people so thought of sharing below:
After doing some research figured out I can safely ignore this message. /robots933456.txt is a dummy URL
the path that App Service uses to check if the container is capable of serving
requests. A 404 response simply indicates that the path doesn't exist, but
it lets App Service know that the container is healthy and ready to respond
to requests.
https://github.com/MicrosoftDocs/azure-docs/issues/32472

Getting 500 server error.. My site works fine and only throws these errors occasionally. How can I better diagnose the problem?

My site works fine locally. It even works fine with my backend using azure web services and front end using netlify but occasionally after several api calls (I'm not overloading the server because these api calls are done one by one) I get LOTS of errors that are all the same. 500 internal server error. I look at the logs and they give me some numbers 500 1013 109 329 2144 391
Reason for this could be
Network issue of your server
Server request time out
-Web app takes too long to respond for a request/response when connecting to any resource( database,different server) etc..
To resolve that , i would suggest you to to increase the idle timeout of your app.
in the app setting of your web app add SCM_COMMAND_IDLE_TIMEOUT = 3600
By default, Web Apps are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable ‘Always On’ to keep the app loaded all the time.
You may also check the diagnostic log stream to get more details on this issue and the blog post for Troubleshooting Azure App Service Apps Using Web Server Logs.
Hope it helps.

Keep a node application running on azure app service

I have deployed a node js web application on app service in azure. Issue is that my application occasionally getting killed for unknown reason. I have done exhaustive search through all the log fines using kudu.
If I restart app service, application starts working.
Is there any way I can restart my node application once it has crashed. Kind of run for ever no matter what. For example if any error happens in an asp.net code deployed in IIS, IIS never crashes, its keeps of serving other incoming request.
Something like using forever/pm2 in azure app service.
node.js in Azure App Services is powered by IISNode, which takes care of everything you described, including monitoring your process for failures and restarting it.
Consider the following POC:
var http = require('http');
http.createServer(function (req, res) {
if (req.url == '/bad') {
throw 'bad';
}
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('bye');
}).listen(process.env.PORT || 1337);
If I host this in a Web App and issue the following sequence of requests:
GET /
GET /bad
GET /
Then the first will yield HTTP 200, the second will throw on the server and yield HTTP 500, and the third will yield HTTP 200 without me having to do anything. IISNode will just detect the crash and restart the process.
So you shouldn't need PM2 or similar solution because this is built in with App Services. However, if you really want to, they now have App Services Preview on Linux, which is powered by PM2 and lets you configure PM2. More on this here. But again you get this out of the box already.
Another thing to consider is Always On setting which is on by default:
By default, web apps are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable Always On to keep the app loaded all the time. If your app runs continuous web jobs, you should enable Always On, or the web jobs may not run reliably.
This is another possible root cause for your issue and the solution is to disable Always On for your Web App (see the link above).
I really want to thank itaysk for your support for this issue.
Issue was not what I was suspecting. Actually the node server was getting restarted on failure correctly.
There was a different issue. Why my website was getting non responsive is for a different reason. Here is what was happening-
We have used rethinkdbdash to connect to rethinkdb database and we was using connection pool. There was a coding/design issue. We have around 15 change feeds implemented with along with socket.io. And the change feed was getting initialised for every user logged in. This was increasing number of active connections in the pool. And rethinkdbdash has default limit of 1000 connection in the pool and as there were lots of live connections, all the available connection in the pool was getting exhausted resulting no more available connection. So, request was waiting for an open connection and it was not getting any available, hence waiting for ever blocking any new requests to be served.

NServiceBus & IIS

NSB 4.6.1
IIS 7.5 - Recyling for this pool is turned off
I am hosting a handler inside of a IIS web appblication which forwards messages to web clients over SignalR. These messages are sent from other NSB services. The problem I run into is that in production the handler for these messages will randomly stop consuming messages from the queue and I have to restart iis to get it to start again. I can't reproduce this issue outside of production, and I cannot find any information in any of my logs.
Anyone have any ideas on what may be causing this?
My NSB configuration
var bus = NServiceBus.Configure.With()
.StructureMapBuilder(container)
.UseTransport<Msmq>()
.UnicastBus()
.PurgeOnStartup(false)
.CreateBus();
can you try to configure IIS as always running and see if the behavior changes?
http://msdn.microsoft.com/en-us/library/ee677261(v=azure.10).aspx
.m

Resources